diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index 4070d32767..0b2a2b216f 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -59,8 +59,46 @@ +let keys = document.getElementsByClassName('key'); +let keyCode = ''; +let audioElement; + +window.onkeydown = function(e){ + + // get keycode + keyCode = e.keyCode; + + // get key with key code + let key = document.querySelector('[data-key="'+keyCode+'"].key'); + + // don't do anything if the key doesn't exist + if(!key) return; + + // get audio with key code + audioElement = document.querySelector('audio[data-key="'+keyCode+'"]') + + // add class to key + key.className = key.className + ' playing'; + // play audio + audioElement.currentTime = 0; + audioElement.play(); + + // remove class from key + setTimeout(function(){ + key.classList.remove('playing'); + }, 100); + +} + +function playSound( audioEl ) { + console.log(audioEl) + audioEl.play(); +} + + + + diff --git a/02 - JS + CSS Clock/index-START.html b/02 - JS + CSS Clock/index-START.html index 2712384201..b35f097a18 100644 --- a/02 - JS + CSS Clock/index-START.html +++ b/02 - JS + CSS Clock/index-START.html @@ -18,7 +18,8 @@ diff --git a/03 - CSS Variables/index-START.html b/03 - CSS Variables/index-START.html index bf0f33e3ba..eeb195cf2f 100644 --- a/03 - CSS Variables/index-START.html +++ b/03 - CSS Variables/index-START.html @@ -15,7 +15,7 @@

Update CSS Variables with JS

- + @@ -25,6 +25,24 @@

Update CSS Variables with JS

/* misc styles, nothing to do with CSS variables */ + :root { + + --base: red; + --spacing: 10px; + --blur: 10px; + + } + + img { + padding: var(--spacing); + background-color:var(--base); + filter: blur(var(--blur)); + } + + .hl { + color: var(--base); + } + body { text-align: center; @@ -53,6 +71,17 @@

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 6e28e357d0..1d7c745889 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -28,28 +28,73 @@ // 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 <= 1599); + console.table(fifteen); + // Array.prototype.map() // 2. Give us an array of the inventory first and last names + const names = inventors.map(inventor=> `${inventor.first}, ${inventor.last}` ); + console.log(names) + // Array.prototype.sort() // 3. Sort the inventors by birthdate, oldest to youngest - + + const oldYoung = inventors.sort((a,b) => (a.year > b.year) ? 1 : -1 ); + console.table(oldYoung) + // Array.prototype.reduce() // 4. How many years did all the inventors live? + const totalYears = inventors.reduce(function(total, inventor){ + return total + (inventor.passed - inventor.year); + }, 0); + console.log(totalYears) + + + inventors.forEach( inventor => inventor.totalLife = inventor.passed - inventor.year ) // 5. Sort the inventors by years lived + const orderedByYearsLived = inventors.sort((a,b) => { + const lastGuy = a.passed - a.year; + const nextGuy = b.passed - b.year; + return lastGuy > nextGuy ? -1 : 1; + }); + console.table(orderedByYearsLived) + + // 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 links = Array.from(document.querySelectorAll('.mw-category a')); + // const de = links + // .map(link => link.innerText) + // .filter(name => name.includes('de')) // 7. sort Exercise // Sort the people alphabetically by last name + const alpha = people.sort( (a,b) => { + const [ alast, afirst ] = a.split(', '); + const [ blast, bfirst ] = b.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' ]; + const sums = data.reduce((start, el) => { + if(!start[el]){ + start[el] = 0; + } + start[el]++; + return start; + }, {}) + console.log(sums) + + + diff --git a/05 - Flex Panel Gallery/index-START.html b/05 - Flex Panel Gallery/index-START.html index e1d643ad5c..9cc6436710 100644 --- a/05 - Flex Panel Gallery/index-START.html +++ b/05 - Flex Panel Gallery/index-START.html @@ -24,6 +24,9 @@ .panels { min-height:100vh; overflow: hidden; + display: flex; + align-items: stretch; + } .panel { @@ -41,6 +44,12 @@ font-size: 20px; background-size:cover; background-position:center; + flex: 1; + justify-content: center; + align-items: center; + display: flex; + flex-direction: column; + } @@ -54,8 +63,17 @@ margin:0; width: 100%; transition:transform 0.5s; + display: flex; + align-items: center; + justify-content: center; + flex: 1 0 auto; } + .panel > *:first-child { transform: translateY(-100%); } + .panel > *:last-child { transform: translateY(100%); } + .panel.open-active > *:first-child { transform: translateY(0); } + .panel.open-active > *:last-child { transform: translateY(0); } + .panel p { text-transform: uppercase; font-family: 'Amatic SC', cursive; @@ -67,6 +85,7 @@ } .panel.open { + flex: 5; font-size:40px; } @@ -75,6 +94,7 @@ text-decoration: none; } + @@ -108,6 +128,25 @@