diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index 4070d32767..ed21f8b278 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -58,7 +58,35 @@ diff --git a/02 - JS + CSS Clock/index-START.html b/02 - JS + CSS Clock/index-START.html index 2712384201..5efd64a07a 100644 --- a/02 - JS + CSS Clock/index-START.html +++ b/02 - JS + CSS Clock/index-START.html @@ -61,13 +61,41 @@ background:black; position: absolute; top:50%; + transform-origin: 100%; + transform: rotate(90deg); + transition: all 0.05s; + transition-timing-function: cubic-bezier(0.68, -0.55, 0.27, 1.55); } diff --git a/03 - CSS Variables/index-START.html b/03 - CSS Variables/index-START.html index 7171607a8b..78a8cbbbcc 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 317883a4c1..9b853f461b 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -31,29 +31,93 @@ // Array.prototype.filter() // 1. Filter the list of inventors for those who were born in the 1500's + const fifteen = inventors.filter((inventor) => { + return inventor.year >= 1500 && inventor.year <= 1600; + }); + + console.log('Born in 1500:'); + console.table(fifteen); // Array.prototype.map() // 2. Give us an array of the inventors' first and last names + const fullNames = inventors.map((inventor) => { + return `${inventor.first} ${inventor.last}`; + }); + console.log('inventors full names:'); + console.log(fullNames); + // Array.prototype.sort() // 3. Sort the inventors by birthdate, oldest to youngest + // this sorts by age not brithdate + const birthdate = inventors.sort((a,b) => { + + return (a.year > b.year ? 1 : -1); + }) + + console.log('Ordered by birthday'); + console.table(birthdate); // Array.prototype.reduce() // 4. How many years did all the inventors live? + const totalYears = inventors.reduce((total, inventor) => { + return total + (inventor.passed - inventor.year); + }, 0) + + console.log('Total Years: '); + console.log(totalYears); + // 5. Sort the inventors by years lived + const oldest = inventors.sort((a,b) => { + const a_age = a.passed - a.year; + const b_age = b.passed - b.year; + + return b_age - a_age; + }) + + console.log('Years lived'); + 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 chrome console + // const list = document.querySelector('.mw-category'); + // const streets = list.querySelectorAll('a'); + // const streetNames = Array.from(streets); + // const streetsWithDe = streetArray.filter((street) => {return street.text.includes('de')}); // 7. sort Exercise // Sort the people alphabetically by last name + const peopleByLastName = people.sort((a,b) => { + const a_names = a.split(', '); + const b_names = b.split(', '); + + console.log(`comparing ${a_names[1]} with ${b_names[1]}`); + const res = a_names[1] > b_names[1] ? a_names[1] : b_names[1]; + console.log(`alpha is ${res}`); + return a_names[1] > b_names[1] ? 1 : -1; + }); + + console.log('People by last names:'); + console.log(peopleByLastName); // 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((object, item) => { + if (!object[item]) { + object[item] = 0; + } + object[item]++; + return object; + }, {}); + + console.log('Transportation grouped:'); + console.log(transportation); + diff --git a/05 - Flex Panel Gallery/index-START.html b/05 - Flex Panel Gallery/index-START.html index e1d643ad5c..c17531b97a 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; + align-items: center; + justify-content: center; + display: flex; + flex-direction: column; } @@ -54,7 +60,16 @@ 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; @@ -68,6 +83,7 @@ .panel.open { font-size:40px; + flex: 5; } .cta { @@ -107,6 +123,28 @@ diff --git a/06 - Type Ahead/index-START.html b/06 - Type Ahead/index-START.html index 1436886918..26ba06a013 100644 --- a/06 - Type Ahead/index-START.html +++ b/06 - Type Ahead/index-START.html @@ -17,6 +17,58 @@ diff --git a/07 - Array Cardio Day 2/index-START.html b/07 - Array Cardio Day 2/index-START.html index 969566ff78..d1f87c63c9 100644 --- a/07 - Array Cardio Day 2/index-START.html +++ b/07 - Array Cardio Day 2/index-START.html @@ -26,16 +26,50 @@ // Some and Every Checks // Array.prototype.some() // is at least one person 19 or older? + const isAdult = people.some((person) => { + const date = new Date; + return date.getFullYear() - person.year > 19 + }) + + console.log('is at least one person 19 or older'); + console.log(isAdult); + // Array.prototype.every() // is everyone 19 or older? + const allAdults = people.every((person) => { + return (new Date).getFullYear() - person.year > 19 + }); + + console.log('is everyone 19 or older?'); + 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 correctComment = comments.find((comment) => { + return comment.id === 823423; + }); + + console.log(`find the comment with the ID of 823423`); + console.log(correctComment); // Array.prototype.findIndex() // Find the comment with this ID // delete the comment with the ID of 823423 + const index = comments.findIndex((comment) => { + return comment.id === 823423; + }); + + const removeComment = comments.splice(index, 1); + + console.log( + `Find the comment with this ID + delete the comment with the ID of 823423` + ); + + console.log(removeComment); + diff --git a/08 - Fun with HTML5 Canvas/index-START.html b/08 - Fun with HTML5 Canvas/index-START.html index 37c148df07..6d45593021 100644 --- a/08 - Fun with HTML5 Canvas/index-START.html +++ b/08 - Fun with HTML5 Canvas/index-START.html @@ -7,8 +7,64 @@ + const canvas = document.querySelector('#draw'); + const ctx = canvas.getContext('2d'); + canvas.width = window.innerWidth; + canvas.height = window.innerHeight; + ctx.strokeStyle = '#BADA55'; + ctx.lineJoin = 'round'; + ctx.lineCap = 'round'; + ctx.lineWidth = 100; + // clours overlay, google globalCompositeOperation + // ctx.globalCompositeOperation = 'multiply'; + let isDrawing = false; + let lastX =0; + let lastY =0; + // http://mothereffinghsl.com/ + let hue = 0; + let direction = true; + + + function draw(e){ + if (!isDrawing) { + return; + } + console.log(e); + ctx.strokeStyle =`hsl(${hue}, 100%, 50%)`; + ctx.beginPath(); + // start from + ctx.moveTo(lastX, lastY); + // go to + ctx.lineTo(e.offsetX, e.offsetY); + ctx.stroke(); + [lastX, lastY] = [e.offsetX, e.offsetY]; + hue++; + if (hue >= 360) { + hue = 0; + } + + if (ctx.lineWidth >= 100 || ctx.lineWidth <= 1) { + direction = !direction; + } + + if (direction) { + ctx.lineWidth++; + } else { + ctx.lineWidth--; + } + } + + + canvas.addEventListener('mousedown', (e) => { + isDrawing = true; + [lastX, lastY] = [e.offsetX, e.offsetY]; + }); + canvas.addEventListener('mousemove', draw); + canvas.addEventListener('mouseup', () => isDrawing = false); + canvas.addEventListener('mouseout', () => isDrawing = false); + +