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..2dc5528222 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -27,25 +27,104 @@ { 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 + 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() + // *** 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 + 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); + // 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')); + + 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