diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index 4070d32767..000c558859 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -59,6 +59,23 @@ diff --git a/02 - JS and CSS Clock/index-START.html b/02 - JS and CSS Clock/index-START.html index ee7eaefb1f..c4c63a2ea1 100644 --- a/02 - JS and CSS Clock/index-START.html +++ b/02 - JS and CSS Clock/index-START.html @@ -62,12 +62,34 @@ background:black; position: absolute; top:50%; + transform-origin: 100%; + transform: rotate(90deg); + transition: all 0.5s; + transition-timing-function: ease-in-out; } diff --git a/03 - CSS Variables/index-START.html b/03 - CSS Variables/index-START.html index ca2b59d077..034a5693dd 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 eec0ffc31d..6198672f70 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -31,28 +31,64 @@ // Array.prototype.filter() // 1. Filter the list of inventors for those who were born in the 1500's + const inventors_born_in_1500s = inventors.filter(i => i.year >= 1500 && i.year < 1600); + + console.table(inventors_born_in_1500s); // Array.prototype.map() // 2. Give us an array of the inventors' first and last names + const inventor_names = inventors.map(i => { + return {first: i.first, last: i.last} + }); + console.table(inventor_names); // Array.prototype.sort() // 3. Sort the inventors by birthdate, oldest to youngest + const inventors_sorted = inventors.sort((a, b) => a.year - b.year); + + console.table(inventors_sorted); // Array.prototype.reduce() // 4. How many years did all the inventors live? + const all_years_lived = inventors.reduce((acc, val) => { + return acc + (val.passed - val.year); + }, 0); + console.log(all_years_lived); // 5. Sort the inventors by years lived + const all_inventors_sorted_by_lived = inventors.sort((a, b) => (a.passed - a.year) - (b.passed - b.year)); + + console.table(all_inventors_sorted_by_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 boulevards = ["Boulevards of Paris", "City walls of Paris", "Thiers wall", "Wall of Charles V", "Wall of Philip II Augustus", "City gates of Paris", "Haussmann's renovation of Paris", "Boulevards of the Marshals", "Boulevard Auguste-Blanqui", "Boulevard Barbès", "Boulevard Beaumarchais", "Boulevard de l'Amiral-Bruix", "Boulevard des Capucines", "Boulevard de la Chapelle", "Boulevard de Clichy", "Boulevard du Crime", "Boulevard Haussmann", "Boulevard de l'Hôpital", "Boulevard des Italiens", "Boulevard de la Madeleine", "Boulevard de Magenta", "Boulevard Montmartre", "Boulevard du Montparnasse", "Boulevard Raspail", "Boulevard Richard-Lenoir", "Boulevard de Rochechouart", "Boulevard Saint-Germain", "Boulevard Saint-Michel", "Boulevard de Sébastopol", "Boulevard de Strasbourg", "Boulevard du Temple", "Boulevard Voltaire", "Boulevard de la Zone"]; + const boulevards_with_de = boulevards.filter(b => b.indexOf('de') > -1); + console.log(boulevards_with_de); // 7. sort Exercise // Sort the people alphabetically by last name + const people_sorted = people.sort((a, b) => { + [a_last, a_first] = a.split(', '); + [b_last, b_first] = b.split(', '); + return a_last > b_last ? 1 : -1; + }); + console.log(people_sorted); // 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 transportation = data.reduce((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 31c9167e16..72bcff0e22 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,8 +60,18 @@ margin:0; width: 100%; transition:transform 0.5s; + /*border: 1px solid red;*/ + 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 { text-transform: uppercase; font-family: 'Amatic SC', cursive; @@ -68,6 +84,7 @@ .panel.open { font-size:40px; + flex: 5; } @@ -102,7 +119,19 @@ diff --git a/06 - Type Ahead/index-START.html b/06 - Type Ahead/index-START.html index 1436886918..126ed365a4 100644 --- a/06 - Type Ahead/index-START.html +++ b/06 - Type Ahead/index-START.html @@ -15,8 +15,43 @@ diff --git a/07 - Array Cardio Day 2/index-START.html b/07 - Array Cardio Day 2/index-START.html index 969566ff78..c884307181 100644 --- a/07 - Array Cardio Day 2/index-START.html +++ b/07 - Array Cardio Day 2/index-START.html @@ -27,14 +27,36 @@ // Some and Every Checks // Array.prototype.some() // is at least one person 19 or older? // Array.prototype.every() // is everyone 19 or older? + const is_adult = people.some(person => { + const currentYear = (new Date()).getFullYear(); + return currentYear - person.year >= 19; + }); + console.log(is_adult); + + const is_all_adult = people.every(person => { + const currentYear = (new Date()).getFullYear(); + return currentYear - person.year >= 19; + }); + + console.log(is_all_adult); // 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 the_comment = comments.find(c => c.id === 823423); + console.log(the_comment); // Array.prototype.findIndex() // Find the comment with this ID // delete the comment with the ID of 823423 + const index = comments.findIndex(c => c.id === 823423); + const new_comments = [ + ...comments.slice(0, index), + ...comments.slice(index+1) + ]; + + console.table(new_comments); + diff --git a/08 - Fun with HTML5 Canvas/index-START.html b/08 - Fun with HTML5 Canvas/index-START.html index 37c148df07..ff833558f7 100644 --- a/08 - Fun with HTML5 Canvas/index-START.html +++ b/08 - Fun with HTML5 Canvas/index-START.html @@ -7,6 +7,63 @@