diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index 4070d32767..c015baeb27 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -58,7 +58,30 @@ diff --git a/02 - JS + CSS Clock/index-START.html b/02 - JS + CSS Clock/index-START.html index 2712384201..63579e2a7a 100644 --- a/02 - JS + CSS Clock/index-START.html +++ b/02 - JS + CSS Clock/index-START.html @@ -61,12 +61,47 @@ background:black; position: absolute; top:50%; + transform-origin:100%; + transform: rotate(90deg); + transition: all 0.05s; + transition-timing-function: cubic-bezier(0.1, 2.7, 0.58, 1); } diff --git a/03 - CSS Variables/index-START.html b/03 - CSS Variables/index-START.html index 7171607a8b..c6c220b940 100644 --- a/03 - CSS Variables/index-START.html +++ b/03 - CSS Variables/index-START.html @@ -21,10 +21,22 @@

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 4162bce339..ab538f49d0 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -33,28 +33,112 @@ // Array.prototype.filter() // 1. Filter the list of inventors for those who were born in the 1500's + // filter will return 2 out of 10 + var fifteen = inventors.filter(function(investor) { + if (investor.year >= 1500 && investor.year < 1599) { + return true;// keep it + } + }); + + // using the reduce to implement filter + // var fifteen = inventors.reduce(function(acc, investor) { + // if (investor.year >= 1500 && investor.year < 1599) { + // acc.push(inventor); + // } + + // return acc; + // }, []); + + + console.log(fifteen); // Array.prototype.map() // 2. Give us an array of the inventors' first and last names + // map return the amount of array you give it + var fullNames = inventors.map(function(investor) { + return investor.first + ' ' + investor.last; + }); + + console.log(fullNames); // Array.prototype.sort() // 3. Sort the inventors by birthdate, oldest to youngest + // two items, return 1, or 1- + + var ordered = inventors.sort(function(firstPerson, secondPerson) { + if (firstPerson.year > secondPerson.year) { + return 1; + } else { + return -1; + } + }); + + // Simple way to implement + //var ordered = inventors.sort((a, b) => a.year > b.year ? 1 : -1); + + console.table(ordered); // Array.prototype.reduce() // 4. How many years did all the inventors live? + var totalYears = inventors.reduce(function(total, investor) { + return total + (investor.passed - investor.year); + }, 0); + console.log(totalYears); + // 5. Sort the inventors by years lived + var oldest = inventors.sort(function(a, b) { + var lastGuy = a.passed - a.year; + var nextGuy = b.passed - b.year; + + if (lastGuy > nextGuy) { + return -1; + } else { + return 1; + } + }); + + console.table(oldest); + // 6. create a list of Boulevards in Paris that contain 'de' anywhere in the name // https://en.wikipedia.org/wiki/Category:Boulevards_in_Paris + // var category = document.querySelector('.mw-category'); + // var links = Array.from(category.querySelectorAll('a')); + + // // + // var de = links.map(function(link) { + // return link.textContent; + // }).filter(function(streetName) { + // return streetName.includes('de'); + // }); // 7. sort Exercise // Sort the people alphabetically by last name + var alpha = people.sort(function(lastOne, nextOne) { + var [aFirst, aLast] = lastOne.split(', '); + var [bFirst, bLast] = nextOne.split(', '); + return aLast > bLast ? 1 : -1 + }); + + + + console.log(alpha); // 8. Reduce Exercise // Sum up the instances of each of these const data = ['car', 'car', 'truck', 'truck', 'bike', 'walk', 'car', 'van', 'bike', 'walk', 'car', 'van', 'car', 'truck' ]; + var transportation = data.reduce(function(obj, item) { + if (!obj[item]) { + obj[item] = 0; + } + + obj[item]++; + return obj; + }, {}); + + console.log(transportation); diff --git a/05 - Flex Panel Gallery/index-START.html b/05 - Flex Panel Gallery/index-START.html index e1d643ad5c..eb7ed7b38f 100644 --- a/05 - Flex Panel Gallery/index-START.html +++ b/05 - Flex Panel Gallery/index-START.html @@ -24,6 +24,7 @@ .panels { min-height:100vh; overflow: hidden; + display: flex; } .panel { @@ -41,6 +42,12 @@ font-size: 20px; background-size:cover; background-position:center; + flex: 1; + justify-content: center; + align-items:center; + display:flex;; + flex-direction: column; + /* display evently*/ } @@ -54,8 +61,17 @@ margin:0; width: 100%; transition:transform 0.5s; + flex: 1 0 auto; + display: flex; + justify-content: center; + align-content: center; } + .panel > *:first-child {transform: translateY(-100%);} + .panel.open-active > *:first-child {transform: translateY(0);} + .panel > *:last-child {transform: translateY(100%);} + .panel.open-active > *:last-child {transform: translateY(0);} + .panel p { text-transform: uppercase; font-family: 'Amatic SC', cursive; @@ -68,6 +84,8 @@ .panel.open { font-size:40px; + flex:5; + } .cta { @@ -107,10 +125,20 @@ - - diff --git a/06 - Type Ahead/index-START.html b/06 - Type Ahead/index-START.html index 1436886918..057ba0255a 100644 --- a/06 - Type Ahead/index-START.html +++ b/06 - Type Ahead/index-START.html @@ -16,6 +16,51 @@ diff --git a/07 - Array Cardio Day 2/index-START.html b/07 - Array Cardio Day 2/index-START.html index 206ec31aa0..c5c9e6f342 100644 --- a/07 - Array Cardio Day 2/index-START.html +++ b/07 - Array Cardio Day 2/index-START.html @@ -26,16 +26,46 @@ // Some and Every Checks // Array.prototype.some() // is at least one person 19? + var isAdult = people.some(function(person) { + var currentYear = (new Date()).getFullYear(); + if (currentYear - person.year >= 19) { + return true; + } + }); + + // var isAdult = people.some(person => { + // var currentYear = (newDate()).getFullYear(); + // return currentYear - person.year >= 19; + // }) + // Array.prototype.every() // is everyone 19? + var allAdult = people.every(person => { + var currentYear = (new Date()).getFullYear(); + return currentYear - person.year >= 19; + }) // Array.prototype.find() // Find is like filter, but instead returns just the one you are looking for + // return the first item you find + var comment = comments.find(comment => comment.id === 823423); + console.log(comment); // find the comment with the ID of 823423 // Array.prototype.findIndex() // Find the comment with this ID // delete the comment with the ID of 823423 + var index = comments.findIndex(comment => comment.id === 823423); + + // splice mutable the array + // comments.splice(index, 1); + // console.table(comments); + + var newComments = [ + ...comments.slice(0, index), + ...comments.slice(index + 1) + ]; + console.table(newComments); diff --git a/08 - Fun with HTML5 Canvas/index-START.html b/08 - Fun with HTML5 Canvas/index-START.html index 37c148df07..f458a6781c 100644 --- a/08 - Fun with HTML5 Canvas/index-START.html +++ b/08 - Fun with HTML5 Canvas/index-START.html @@ -7,6 +7,54 @@