From 75cec86a609af688582bee05ed67639608d93504 Mon Sep 17 00:00:00 2001 From: CATHY CHAN Date: Sat, 24 Dec 2016 11:39:08 -0500 Subject: [PATCH 1/8] completed exercises 3 1-3 --- 01 - JavaScript Drum Kit/index-START.html | 22 ++++++++++++++++++ 02 - JS + CSS Clock/index-START.html | 28 +++++++++++++++++++++++ 03 - CSS Variables/index-START.html | 26 +++++++++++++++++++++ 04 - Array Cardio Day 1/index-START.html | 23 +++++++++++++++++++ 4 files changed, 99 insertions(+) diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index 4070d32767..b8d6c8a7a5 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -58,7 +58,29 @@ diff --git a/02 - JS + CSS Clock/index-START.html b/02 - JS + CSS Clock/index-START.html index 2712384201..0dc826d16b 100644 --- a/02 - JS + CSS Clock/index-START.html +++ b/02 - JS + CSS Clock/index-START.html @@ -61,12 +61,40 @@ background:black; position: absolute; top:50%; + transform: rotate(90deg); + transform-origin: 100%; + transition: all 0.5s;. + transition-timing-function: cubic-bezier(0, 2.49, 0.24, 1.18); } diff --git a/03 - CSS Variables/index-START.html b/03 - CSS Variables/index-START.html index 7171607a8b..d954015401 100644 --- a/03 - CSS Variables/index-START.html +++ b/03 - CSS Variables/index-START.html @@ -21,7 +21,21 @@

Update CSS Variables with JS

diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index 317883a4c1..00437feba1 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -27,13 +27,36 @@ { first: 'Hanna', last: 'Hammarström', year: 1829, passed: 1909 } ]; + const flavours = ['Chocolate Chip', 'Kulfi', 'Caramel Praline', 'Chocolate', 'Burnt Caramel', 'Pistachio', 'Rose', 'Sweet Coconut', 'Lemon Cookie', 'Toffeeness', 'Toasted Almond', 'Black Raspberry Crunch', 'Chocolate Brownies', 'Pistachio Almond', 'Strawberry', 'Lavender Honey', 'Lychee', 'Peach', 'Black Walnut', 'Birthday Cake', 'Mexican Chocolate', 'Mocha Almond Fudge', 'Raspberry']; + const people = ['Beck, Glenn', 'Becker, Carl', 'Beckett, Samuel', 'Beddoes, Mick', 'Beecher, Henry', 'Beethoven, Ludwig', 'Begin, Menachem', 'Belloc, Hilaire', 'Bellow, Saul', 'Benchley, Robert', 'Benenson, Peter', 'Ben-Gurion, David', 'Benjamin, Walter', 'Benn, Tony', 'Bennington, Chester', 'Benson, Leana', 'Bent, Silas', 'Bentsen, Lloyd', 'Berger, Ric', 'Bergman, Ingmar', 'Berio, Luciano', 'Berle, Milton', 'Berlin, Irving', 'Berne, Eric', 'Bernhard, Sandra', 'Berra, Yogi', 'Berry, Halle', 'Berry, Wendell', 'Bethea, Erin', 'Bevan, Aneurin', 'Bevel, Ken', 'Biden, Joseph', 'Bierce, Ambrose', 'Biko, Steve', 'Billings, Josh', 'Biondo, Frank', 'Birrell, Augustine', 'Black Elk', 'Blair, Robert', 'Blair, Tony', 'Blake, William']; // Array.prototype.filter() // 1. Filter the list of inventors for those who were born in the 1500's + const fifteen = inventors.filter(inventor => (inventor.year >= 1500 && inventor.year < 1600)); + // refactored! + + // const fifteen = inventors.filter(function(inventor){ + // if (inventor.year >= 1500 && inventor.year < 1600){ + // return true; + // } + // }); + + // console.table(fifteen); + // Array.prototype.map() + // gives same amount of items as you give it // 2. Give us an array of the inventors' first and last names + const full = inventors.map(inventor => inventor.first + ' ' + inventor.last); + + // refactored! + // const full = inventors.map(function(inventor){ + // return inventor.first + ' ' + inventor.last; + // }); + + console.log(full); + // Array.prototype.sort() // 3. Sort the inventors by birthdate, oldest to youngest From c3763866ae3844ece99b77ababfc356b75528551 Mon Sep 17 00:00:00 2001 From: CATHY CHAN Date: Sat, 24 Dec 2016 12:16:55 -0500 Subject: [PATCH 2/8] sort oldest to youngest --- 04 - Array Cardio Day 1/index-START.html | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index 00437feba1..69e7bcb80c 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -48,7 +48,7 @@ // Array.prototype.map() // gives same amount of items as you give it // 2. Give us an array of the inventors' first and last names - const full = inventors.map(inventor => inventor.first + ' ' + inventor.last); + const full = inventors.map(inventor => `${inventor.first} ${inventor.last}`); // refactored! // const full = inventors.map(function(inventor){ @@ -60,6 +60,20 @@ // Array.prototype.sort() // 3. Sort the inventors by birthdate, oldest to youngest + const oldestSort = inventors.sort((a,b) => a.year > b.year ? 1: -1) + + // refactored! + // const oldestSort = inventors.sort(function(a,b){ + // if (a.year>b.year){ + // return 1; + // } else { + // return -1 + // } + // }); + + console.table(oldestSort); + + // Array.prototype.reduce() // 4. How many years did all the inventors live? From 32cad60ed6bb263c0401def016b71785b1714c86 Mon Sep 17 00:00:00 2001 From: CATHY CHAN Date: Sat, 24 Dec 2016 13:26:49 -0500 Subject: [PATCH 3/8] generated total of years inventors lived --- 04 - Array Cardio Day 1/index-START.html | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index 69e7bcb80c..c3ad1e1be2 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -42,11 +42,11 @@ // } // }); - // console.table(fifteen); + console.table(fifteen); // Array.prototype.map() - // gives same amount of items as you give it + // *** gives same amount of items as you give it // 2. Give us an array of the inventors' first and last names const full = inventors.map(inventor => `${inventor.first} ${inventor.last}`); @@ -74,9 +74,13 @@ console.table(oldestSort); - // Array.prototype.reduce() + // *** allows you to build sth on every single one // 4. How many years did all the inventors live? + const totalYears = inventors.reduce((total, inventor) => { + return total + (inventor.passed - inventor.year); + },0); + console.log(totalYears); // 5. Sort the inventors by years lived From ee104c1ca4cebda288c6800d1617480d1dbe4eb6 Mon Sep 17 00:00:00 2001 From: CATHY CHAN Date: Sat, 24 Dec 2016 14:00:19 -0500 Subject: [PATCH 4/8] sort inventors by years lived --- 04 - Array Cardio Day 1/index-START.html | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index c3ad1e1be2..bb57d9fa59 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -83,6 +83,15 @@ console.log(totalYears); // 5. Sort the inventors by years lived + const ages = inventors.sort(function(a,b){ + if (a.passed-a.year > b.passed-b.year){ + return 1; + } else{ + return -1; + }; + }); + console.table(ages); + // 6. create a list of Boulevards in Paris that contain 'de' anywhere in the name // https://en.wikipedia.org/wiki/Category:Boulevards_in_Paris From 05de2758af4832feb691f3a267b756188b80792c Mon Sep 17 00:00:00 2001 From: CATHY CHAN Date: Sat, 24 Dec 2016 14:02:29 -0500 Subject: [PATCH 5/8] refactored years lived --- 04 - Array Cardio Day 1/index-START.html | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index bb57d9fa59..11020077f0 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -83,13 +83,16 @@ console.log(totalYears); // 5. Sort the inventors by years lived - const ages = inventors.sort(function(a,b){ - if (a.passed-a.year > b.passed-b.year){ - return 1; - } else{ - return -1; - }; - }); + const ages = inventors.sort((a,b) => (a.passed-a.year > b.passed - b.year) ? 1:-1); + + // refactored! + // const ages = inventors.sort(function(a,b){ + // if (a.passed-a.year > b.passed-b.year){ + // return 1; + // } else{ + // return -1; + // }; + // }); console.table(ages); From 6151e327c40f7f65296d5932c5f408deaf577ee1 Mon Sep 17 00:00:00 2001 From: CATHY CHAN Date: Sun, 25 Dec 2016 11:04:47 -0500 Subject: [PATCH 6/8] modified years lived sort to descending order --- 04 - Array Cardio Day 1/index-START.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index 11020077f0..b5b7996ae4 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -83,14 +83,14 @@ console.log(totalYears); // 5. Sort the inventors by years lived - const ages = inventors.sort((a,b) => (a.passed-a.year > b.passed - b.year) ? 1:-1); + const ages = inventors.sort((a,b) => (a.passed-a.year > b.passed - b.year) ? -1:1); // refactored! // const ages = inventors.sort(function(a,b){ // if (a.passed-a.year > b.passed-b.year){ - // return 1; - // } else{ // return -1; + // } else{ + // return 1; // }; // }); console.table(ages); From 065df695836cc4a505d3a1ce7e6102a132ae32b6 Mon Sep 17 00:00:00 2001 From: CATHY CHAN Date: Sun, 25 Dec 2016 12:40:53 -0500 Subject: [PATCH 7/8] grabbed list of street names and filtered names containing 'de' --- 04 - Array Cardio Day 1/index-START.html | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index c3ad1e1be2..afe4c59715 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -86,6 +86,21 @@ // 6. create a list of Boulevards in Paris that contain 'de' anywhere in the name // https://en.wikipedia.org/wiki/Category:Boulevards_in_Paris + const category = document.querySelector('.mw-category'); + + // this gives you nodeList, not array! + // const links = category.querySelectorAll('a'); + + // can convery with ES6 + // const links = [...category.querySelectorAll('a')]; + + // can convert with Array.from(...) + const links = Array.from(category.querySelectorAll('a')); + + // select all names + const de = links + .map(link => link.textContent) + .filter(streetName => streetName.includes('de')); // 7. sort Exercise From d2c7ac23f03eeb3bd1a0f1b3553979357d5f4221 Mon Sep 17 00:00:00 2001 From: CATHY CHAN Date: Sun, 25 Dec 2016 12:41:32 -0500 Subject: [PATCH 8/8] removed names containing 'des' from list --- 04 - Array Cardio Day 1/index-START.html | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index afe4c59715..78c97f440d 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -102,6 +102,17 @@ .map(link => link.textContent) .filter(streetName => streetName.includes('de')); + let removeDes = []; + de.forEach(function(name){ + let splitName = name.split(' '); + if(splitName.includes('des')){ + return; + }else{ + removeDes.push(name); + } + }); + + console.log(removeDes); // 7. sort Exercise // Sort the people alphabetically by last name