diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index 4070d32767..01382bc186 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -59,6 +59,25 @@ diff --git a/02 - JS + CSS Clock/index-START.html b/02 - JS + CSS Clock/index-START.html index 2712384201..aa0ac58c10 100644 --- a/02 - JS + CSS Clock/index-START.html +++ b/02 - JS + CSS Clock/index-START.html @@ -61,12 +61,36 @@ background:black; position: absolute; top:50%; + transform-origin: 100%; + transform: rotate(90deg); + transition: all 0.05s; + transition-timing-function: cubic-bezier(0.2, 3.0, 0.6, 1.08); } diff --git a/03 - CSS Variables/index-START.html b/03 - CSS Variables/index-START.html index ca2b59d077..e467263075 100644 --- a/03 - CSS Variables/index-START.html +++ b/03 - CSS Variables/index-START.html @@ -15,13 +15,43 @@

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 eec0ffc31d..472a2ada35 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -32,27 +32,110 @@ // Array.prototype.filter() // 1. Filter the list of inventors for those who were born in the 1500's + const born_in_1500s = inventors.filter(inventor => + (inventor.year > 1499 && inventor.year < 1600) + ) + + console.table(born_in_1500s) + // Array.prototype.map() // 2. Give us an array of the inventors' first and last names + const name_array = inventors.map(inventor => inventor.first + ' ' + inventor.last) + + console.log(name_array) + // Array.prototype.sort() // 3. Sort the inventors by birthdate, oldest to youngest + // const inventors_by_birthday = inventors.sort(function(inventorA, inventorB) { + // if(inventorA.year < inventorB.year) { + // return -1 + // } + // if(inventorA.year > inventorB.year) { + // return 1 + // } + // else { + // return 0 + // } + // }) + + const inventors_by_birthday = inventors.sort((inventorA, inventorB) => inventorA.year > inventorB.year ? 1 : -1) + + console.table(inventors_by_birthday) + // Array.prototype.reduce() // 4. How many years did all the inventors live? + const total_inventor_life = inventors.reduce((total, inventor) => { + return (total + (inventor.passed - inventor.year)); + }, 0) + + console.log(total_inventor_life) + // 5. Sort the inventors by years lived + // const inventors_by_years_lived = inventors.sort(function(inventorA, inventorB) { + // if((inventorA.passed - inventorA.year) < (inventorB.passed - inventorB.year)) { + // return -1 + // } + // if((inventorA.passed - inventorA.year) > (inventorB.passed - inventorB.year)) { + // return 1 + // } + // else { + // return 0 + // } + // }) + + const inventors_by_years_lived = inventors.sort((inventorA, inventorB) => (inventorA.passed-inventorA.year) < (inventorB.passed-inventorB.year) ? -1 : 1) + + console.table(inventors_by_years_lived) + // 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'); + // const links = [...category.querySelectorAll('a')]; + // // or, Array.from(category.querySelectorAll('a')) + // const blvd_names = links.map(link => link.textContent); + // const de_blvds = blvd_names.filter(blvd => ( + // blvd.indexOf('de')> 0) + // ) // 7. sort Exercise // Sort the people alphabetically by last name + const sorted_people = people.sort((personA, personB) => ( + // let personALastName = personA.split(', ')[0].toLowerCase(); + // let personBLastName = personB.split(', ')[0].toLowerCase(); + (personA.split(', ')[0].toLowerCase() < personB.split(', ')[0].toLowerCase()) ? -1 : 1 + )) + + // const sorted_people = people.sort(function(personA, personB) { + // if(personA.split(', ')[0].toLowerCase() < personB.split(', ')[0].toLowerCase()) { + // return -1 + // } + // if(personA.split(', ')[0].toLowerCase() > personB.split(', ')[0].toLowerCase()) { + // return 1 + // } + // else { + // return 0 + // } + // }) + console.log(sorted_people) + // 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' ]; + const transport = data.reduce(function(allItems, item) { + if (item in allItems) { + allItems[item]++; + } + else { + allItems[item] = 1 + } + return allItems; + }, {}); + console.log(transport); diff --git a/05 - Flex Panel Gallery/index-START.html b/05 - Flex Panel Gallery/index-START.html index e1d643ad5c..9eb07fda53 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,11 @@ font-size: 20px; background-size:cover; background-position:center; + flex: 1; + justify-content: center; + align-items: center; + display: flex; + flex-direction: column; } @@ -54,6 +60,24 @@ margin:0; width: 100%; transition:transform 0.5s; + flex: 1 0 auto; + display: flex; + justify-content: center; + align-items: 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 { @@ -67,6 +91,7 @@ } .panel.open { + flex: 5; font-size:40px; } @@ -108,6 +133,22 @@ diff --git a/06 - Type Ahead/index-START.html b/06 - Type Ahead/index-START.html index 1436886918..10a5c9b37c 100644 --- a/06 - Type Ahead/index-START.html +++ b/06 - Type Ahead/index-START.html @@ -17,6 +17,82 @@ diff --git a/07 - Array Cardio Day 2/index-START.html b/07 - Array Cardio Day 2/index-START.html index 969566ff78..587fb2d6a4 100644 --- a/07 - Array Cardio Day 2/index-START.html +++ b/07 - Array Cardio Day 2/index-START.html @@ -25,17 +25,75 @@ ]; // Some and Every Checks - // Array.prototype.some() // is at least one person 19 or older? - // Array.prototype.every() // is everyone 19 or older? + // Array.prototype.some() // is at least one person 19? + + // const isAdult = people.some(person => { + // const currentYear = (new Date()).getFullYear(); + // if(currentYear - person.year >= 19) { + // return true; + // } + // }) + + const isAdult = people.some(person => { + let currentYear = (new Date()).getFullYear(); + return currentYear - person.year >= 19; + }) + + console.log({isAdult}); + + // const isAdult = people.some(function(person) { + // const currentYear = (new Date()).getFullYear(); + // if(currentYear - person.year >= 19) { + // return true; + // } + // }); + + // const isAdult = people.some(person => ((new Date()).getFullYear()) - person.year >= 19); + + // console.log({isAdult}); + // Array.prototype.every() // is everyone 19? + + const allAdults = people.every(person => { + let currentYear = (new Date()).getFullYear(); + return currentYear - person.year >= 19; + }) + + // const allAdults = people.every(person => ((new Date()).getFullYear()) - person.year >= 19); + console.log({allAdults}); // Array.prototype.find() // Find is like filter, but instead returns just the one you are looking for // find the comment with the ID of 823423 + const comment = comments.find(comment => ( + comment.id === 823423 + ) + ) + + // const comment = comments.find(comment => comment.id === 823423); + + console.log(comment); // Array.prototype.findIndex() // Find the comment with this ID // delete the comment with the ID of 823423 + const index = comments.findIndex(comment => comment.id === 823423); + + // const index = comments.findIndex(comment => comment.id === 823423); + + console.log(index); + + comments.splice(index, 1); + // console.table(comments) + + const 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..6e9aaf14dd 100644 --- a/08 - Fun with HTML5 Canvas/index-START.html +++ b/08 - Fun with HTML5 Canvas/index-START.html @@ -7,6 +7,57 @@ diff --git a/17 - Sort Without Articles/index-START.html b/17 - Sort Without Articles/index-START.html index cfaf3e0440..0065bd97cb 100644 --- a/17 - Sort Without Articles/index-START.html +++ b/17 - Sort Without Articles/index-START.html @@ -44,7 +44,30 @@ diff --git a/18 - Adding Up Times with Reduce/index-START.html b/18 - Adding Up Times with Reduce/index-START.html index 3eaee0f3ef..060819798e 100644 --- a/18 - Adding Up Times with Reduce/index-START.html +++ b/18 - Adding Up Times with Reduce/index-START.html @@ -182,6 +182,36 @@ diff --git a/19 - Webcam Fun/index.html b/19 - Webcam Fun/index.html index d4ffc4dc2a..65a3758e35 100755 --- a/19 - Webcam Fun/index.html +++ b/19 - Webcam Fun/index.html @@ -10,7 +10,10 @@
-