diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index 4070d32767..5d7533cbff 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -59,6 +59,32 @@ diff --git a/02 - JS + CSS Clock/index-START.html b/02 - JS + CSS Clock/index-START.html index 2712384201..2a81021d2f 100644 --- a/02 - JS + CSS Clock/index-START.html +++ b/02 - JS + CSS Clock/index-START.html @@ -61,13 +61,36 @@ background:black; position: absolute; top:50%; + transform-origin: 100%; + transform: rotate(90deg); + transition: all 0.5s; + 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..ba0e2510d2 100644 --- a/03 - CSS Variables/index-START.html +++ b/03 - CSS Variables/index-START.html @@ -9,10 +9,10 @@

Update CSS Variables with JS

- + - + @@ -20,11 +20,25 @@

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..11008d7671 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -32,28 +32,101 @@ // Array.prototype.filter() // 1. Filter the list of inventors for those who were born in the 1500's + // with an implicit return. It returns true if this statement is true. + const inventorsFrom1500s = inventors.filter(inventor => + inventor.year <= 1600 && inventor.year >= 1500 + ) + // console.log('Let\s see if this works', inventorsFrom1500s); // Array.prototype.map() // 2. Give us an array of the inventors' first and last names + // reWritten with the implicit return. Each object is transformed into a part of what it once was. + const inventorFirstAndLast = inventors.map(inventor => + [inventor.first, inventor.last] + ) + + // console.log('testing 1, 2, 3', inventorFirstAndLast); // Array.prototype.sort() // 3. Sort the inventors by birthdate, oldest to youngest + // is a.year is greater than b.year, then this is true and you return 1, which means don't swap, I believe. Yep, when b < a you switch the two, otherwise they stay the same, so 1890 > 1898, switch. + // 1905 > 1898, false, returns -1, means that you DO want to switch the two values. + const inventorSorting = inventors.sort((a, b) => + // console.log('Returning this', a.year > b.year ? 1 : -1); + a.year > b.year ? 1 : -1 + ) + // console.log('birthdate oldest to youngest'); + // console.table( inventorSorting) + // Array.prototype.reduce() // 4. How many years did all the inventors live? + // the first parameter is the accumulator, so it needs to be the same type as the starting value, + // whatever that is. The reduce will continue to run through all the inventors and add 'em up. + const inventorSum = inventors.reduce((total, inventor) => + total + (inventor.passed - inventor.year) + , 0) + + // console.log('the total age of everyone lived is', inventorSum); // 5. Sort the inventors by years lived + // console.log('years lived youngest to oldest'); + const inventorsByYearsLived = inventors.sort((a, b) => + (a.passed - a.year) > (b.passed - b.year) + ) + // console.table( inventorsByYearsLived); // 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')]; + // var de = links.map(link => + // link.textContent + // ).filter(streetName => + // streetName.includes('de') + // ) + + // const birthdays = [...document.querySelectorAll('.celebs-box')]; + + // const textContent = birthdays.map(celebBox => + // celebBox.textContent + // ) + // joinedCelebs = textContent.join('').split('\u21b5'); + + // 7. sort Exercise // Sort the people alphabetically by last name + const sortedPeople = people.sort((a, b) => { + a = a.split(','); + a = a[0] + b = b.split(','); + b = b[0] + + // console.log('a > b is', a > b ? 1 : -1); + // return a - b; + return a > b ? 1 : -1; + // console.log('commaLocation is', commaLocation); + }) + + // console.log('sortedPeople', sortedPeople); + // 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' ]; + // note how obj is starting blank. + const wayOfTransport = data.reduce((obj, transport) => { + if(!obj[transport]){ + obj[transport] = 0; + } + obj[transport] += 1; + return obj; + }, {}) + + console.log('wayOfTransport', wayOfTransport); + diff --git a/05 - Flex Panel Gallery/index-START.html b/05 - Flex Panel Gallery/index-START.html index e1d643ad5c..2d810531f8 100644 --- a/05 - Flex Panel Gallery/index-START.html +++ b/05 - Flex Panel Gallery/index-START.html @@ -16,16 +16,21 @@ } body { margin: 0; - } + } *, *:before, *:after { box-sizing: inherit; } +/* display: flex puts everything in one flex box, changes the panels from being vertically aligned to +horizontally aligned */ .panels { min-height:100vh; overflow: hidden; + display: flex; } +/* flex: 1 tells the panels to fill out all remaining space, basically take over the page */ +/*you can add display: flex to items that are already in flexboxes. you can put flexboxes in flexboxes*/ .panel { background:#6B0F9C; box-shadow:inset 0 0 0 5px rgba(255,255,255,0.1); @@ -34,13 +39,19 @@ align-items:center; /* Safari transitionend event.propertyName === flex */ /* Chrome + FF transitionend event.propertyName === flex-grow */ + /*need this transition or the whole thing breaks. It because of the flex statement in here*/ transition: font-size 0.7s cubic-bezier(0.61,-0.19, 0.7,-0.11), - flex 0.7s cubic-bezier(0.61,-0.19, 0.7,-0.11), + flex 0.7s cubic-bezier(0.61,-0.19, 0.7,-0.11); background 0.2s; font-size: 20px; background-size:cover; background-position:center; + flex: 1; + justify-content: center; + align-items: center; + display: flex; + flex-direction: column; } @@ -50,10 +61,29 @@ .panel4 { background-image:url(https://source.unsplash.com/ITjiVXcwVng/1500x1500); } .panel5 { background-image:url(https://source.unsplash.com/3MNzGlQM7qs/1500x1500); } + /* these are everything inside of a flex panel. I.E. all of the

tags */ .panel > * { margin:0; width: 100%; transition:transform 0.5s; + flex: 1 0 auto; + display: flex; + justify-content: center; + align-items: center; + } + + /*Transform causes CSS fields to move. The translate -100% will move the first-child of every Panel off-screen going up, while the other will do the opposite to the last-child. When they are deactivated the items come back*/ + .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 { @@ -66,8 +96,10 @@ font-size: 4em; } + /*flex of 5 means that this panel will take 5 times the amount of extra room as the rest of the panels when it is open*/ .panel.open { font-size:40px; + flex: 5; } .cta { @@ -108,6 +140,30 @@ diff --git a/06 - Type Ahead/index-START.html b/06 - Type Ahead/index-START.html index 1436886918..33653e6c4a 100644 --- a/06 - Type Ahead/index-START.html +++ b/06 - Type Ahead/index-START.html @@ -17,6 +17,70 @@ diff --git a/07 - Array Cardio Day 2/index-START.html b/07 - Array Cardio Day 2/index-START.html index 969566ff78..2a5290417a 100644 --- a/07 - Array Cardio Day 2/index-START.html +++ b/07 - Array Cardio Day 2/index-START.html @@ -26,16 +26,64 @@ // Some and Every Checks // Array.prototype.some() // is at least one person 19 or older? + + // returns true for at least one person. + const overNineteen = (person => { + const currentDate = new Date().getFullYear(); + // if it's true for one person, then we are solid. + if(currentDate - person.year >= 19){ + return true; + } + + }) + + const anyAdults = people.some(overNineteen); + + // console.log(anyAdults); // Array.prototype.every() // is everyone 19 or older? + const allAdults = people.every(overNineteen); + + // 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 findComment = (comment => { + if(comment.id === 823423){ + return comment; + } + }) + + // comments.find already means you're going to be using the comments array. Don't need to pass that in to findComment. All you need to do is add the logic to find the specific comment you're looking for, + // console.log(comments.find(findComment)); + // Array.prototype.findIndex() // Find the comment with this ID // delete the comment with the ID of 823423 + // the findIndex returns the index automatically, it doesn't matter what you add as the return to the function, oddly. + + const index = comments.findIndex(comment =>{ + if(comment.id === 823423){ + return true; + } + }) + + // comments.splice(index, 1); + + // console.log(comments); + + const newComments = [ + ...comments.slice(0, index), + // the first one slices everything from zero to the index (not inclusive of index) + // the second slice from one past the index all the way to the end of the comments array. + ...comments.slice(index + 1) + ] + + console.log(newComments) + diff --git a/08 - Fun with HTML5 Canvas/index-START.html b/08 - Fun with HTML5 Canvas/index-START.html index 37c148df07..23569b1887 100644 --- a/08 - Fun with HTML5 Canvas/index-START.html +++ b/08 - Fun with HTML5 Canvas/index-START.html @@ -5,8 +5,81 @@ HTML5 Canvas +