diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index 4070d32767..916cbbd9e6 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -59,6 +59,30 @@ diff --git a/02 - JS + CSS Clock/index-START.html b/02 - JS + CSS Clock/index-START.html index 2712384201..828dca02fa 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-origin: 100%; + transform: rotate(90deg); + transition: all 0.05s; + /* transition-timing-function: cubic-bezier: adjusts appearance of motion*/ + transition-timing-function: cubic-bezier(.1, 2.7, .58, 1); } diff --git a/03 - CSS Variables/index-START.html b/03 - CSS Variables/index-START.html index 7171607a8b..dae79e9bb6 100644 --- a/03 - CSS Variables/index-START.html +++ b/03 - CSS Variables/index-START.html @@ -21,6 +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 4162bce339..247958ff63 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -33,29 +33,106 @@ // 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) + console.table(fifteen); // Array.prototype.map() // 2. Give us an array of the inventors' first and last names + //will always return the same number of items as you give it + // const fullNames = inventors.map(inventor => + // inventor.first + ' ' + inventor.last); + // console.log(fullNames); + // //or + const fullNames = inventors.map(inventor => + `${inventor.first} ${inventor.last}`); + console.log(fullNames); // Array.prototype.sort() // 3. Sort the inventors by birthdate, oldest to youngest + //you get two items and you have to sort those two + + // const ordered = inventors.sort(function(a, b){ + // if (a.year > b.year){ + // return 1; + // } else { + // return -1; + // } + // }) + + // console.table(ordered) + //or + + const 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? + const totalYears = inventors.reduce((total, inventor) => { + return total + (inventor.passed - inventor.year); + //to get the number of years they lived + }, 0) + console.log(totalYears); // 5. Sort the inventors by years lived + const oldest = inventors.sort(function(a, b){ + const lastGuy = a.passed - a.year; + const nextGuy = b.passed - b.year; + return lastGuy > nextGuy ? -1 : 1; + // 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 + //IN CONSOLE OF WIKI PAGE^ + //dev tools + // +// const category = document.querySelector('.mw-category'); +// const links = Array.from(category.querySelectorAll('a')); +// //convert list of links to list of names +// //array.from will make it into an array from the nodelist + +// const de = links +// .map(link => link.textContent) +// //will give the text inside of each link +// .filter(streetName => streetName.includes('de')); +// //will filter them out // 7. sort Exercise // Sort the people alphabetically by last name + const alpha = people.sort((lastOne, nextOne) => { + // console.log(lastOne); + const [last, first] = lastOne.split(', '); + const [lastN, firstN] = nextOne.split(', '); + // console.log(last, first); + // console.log(lastN, firstN); + return last > lastN ? 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' ]; + const transportation = data.reduce(function(obj, item) { + if (!obj[item]){ + obj[item] = 0; + } + + // console.log(item); + 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..70b00a94db 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,13 @@ font-size: 20px; background-size:cover; background-position:center; + flex: 1; + /*which means that they'll evenly distribute*/ + justify-content: center; + align-items: center; + display: flex; + flex-direction: column; + /* nest the flex box*/ } @@ -54,8 +62,17 @@ 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 { text-transform: uppercase; font-family: 'Amatic SC', cursive; @@ -67,6 +84,8 @@ } .panel.open { + flex: 5; + /*flex of 5 means that when it has the class of open, it's going to be 5x the size of the rest of them*/ font-size:40px; } @@ -107,6 +126,21 @@ diff --git a/06 - Type Ahead/index-START.html b/06 - Type Ahead/index-START.html index 1436886918..a79d8e7fa2 100644 --- a/06 - Type Ahead/index-START.html +++ b/06 - Type Ahead/index-START.html @@ -17,6 +17,62 @@ diff --git a/07 - Array Cardio Day 2/index-START.html b/07 - Array Cardio Day 2/index-START.html index 206ec31aa0..919b4af4d6 100644 --- a/07 - Array Cardio Day 2/index-START.html +++ b/07 - Array Cardio Day 2/index-START.html @@ -26,9 +26,45 @@ // Some and Every Checks // Array.prototype.some() // is at least one person 19? - // Array.prototype.every() // is everyone 19? + //will return true if there is at least one adult in people array who is over 19 + + // const isAdult = people.some(function(person){ + // const currentYear = (new Date()).getFullYear(); + // if(currentYear - person.year >= 19){ + // return true; + // } + // }); + // console.log(isAdult); + //or + + const isAdult = people.some(person => { + const currentYear = (new Date()).getFullYear(); + return currentYear - person.year >= 19; + }); + console.log(isAdult); + + // Array.prototype.every() // is everyone 19? + const allAdult = people.every(person => { + const currentYear = (new Date()).getFullYear(); + return currentYear - person.year >= 19; + }); + console.log(allAdult); + + + // // Array.prototype.find() + // const theComment = comments.find(function(comment) { + // if(comment.id === 823423){ + // return true; + // } + // }); + // console.log(theComment); + //or + + const theComment = comments.find(comment => + comment.id === 823423); + console.log(theComment); + - // 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 @@ -36,6 +72,21 @@ // Find the comment with this ID // delete the comment with the ID of 823423 + const index = comments.findIndex(comment => + comment.id === 823423); + console.log('index', index); + + // comments.splice(index, 1); + + //popular in redux world: + const newComments = [ + ...comments.slice(0, index), + ...comments.slice(index + 1) + ]; + + //will build new array of comments + //... will spread items into new array + diff --git a/08 - Fun with HTML5 Canvas/index-START.html b/08 - Fun with HTML5 Canvas/index-START.html index 37c148df07..a202e24901 100644 --- a/08 - Fun with HTML5 Canvas/index-START.html +++ b/08 - Fun with HTML5 Canvas/index-START.html @@ -7,6 +7,71 @@