diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index 4070d32767..6b54c3a1fa 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -1,66 +1,82 @@ - - - JS Drum Kit - - - - - -
-
- A - clap -
-
- S - hihat -
-
- D - kick -
-
- F - openhat -
-
- G - boom + + + JS Drum Kit + + + +
+
+ A + clap +
+
+ S + hihat +
+
+ D + kick +
+
+ F + openhat +
+
+ G + boom +
+
+ H + ride +
+
+ J + snare +
+
+ K + tom +
+
+ L + tink +
-
- H - ride -
-
- J - snare -
-
- K - tom -
-
- L - tink -
-
- - - - - - - - - - - + + diff --git a/02 - JS and CSS Clock/clock.js b/02 - JS and CSS Clock/clock.js new file mode 100644 index 0000000000..3516445b47 --- /dev/null +++ b/02 - JS and CSS Clock/clock.js @@ -0,0 +1,24 @@ +const secondHand = document.querySelector('.second-hand'); +const minuteHand = document.querySelector('.min-hand'); +const hourHand = document.querySelector('.hour-hand'); + +const setTime = () => { + const now = new Date(); + const hour = now.getHours(); + const minute = now.getMinutes(); + const second = now.getSeconds(); + + let rotation; + + rotation = second * 6 + 90; + secondHand.style.transform = `rotate(${rotation}deg)`; + + rotation = (minute + second / 60) * 6 + 90; + minuteHand.style.transform = `rotate(${rotation}deg)`; + + rotation = (hour + minute / 60) * 30 + 90; + hourHand.style.transform = `rotate(${rotation}deg)`; +}; + +setTime(); +setInterval(setTime, 1000); diff --git a/02 - JS and CSS Clock/index-FINISHED.html b/02 - JS and CSS Clock/index-FINISHED.html index 04d1a4e40e..0046e4a2d0 100644 --- a/02 - JS and CSS Clock/index-FINISHED.html +++ b/02 - JS and CSS Clock/index-FINISHED.html @@ -1,12 +1,10 @@ - - - JS + CSS Clock - - - - + + + JS + CSS Clock + +
@@ -15,85 +13,82 @@
- - - - - + + + + diff --git a/02 - JS and CSS Clock/index-START.html b/02 - JS and CSS Clock/index-START.html index 7a6d27d5bd..a4194a9874 100644 --- a/02 - JS and CSS Clock/index-START.html +++ b/02 - JS and CSS Clock/index-START.html @@ -1,12 +1,10 @@ - - - JS + CSS Clock - - - - + + + JS + CSS Clock + +
@@ -15,60 +13,55 @@
+ + .clock { + width: 30rem; + height: 30rem; + border: 20px solid white; + border-radius: 50%; + margin: 50px auto; + position: relative; + padding: 2rem; + box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.1), inset 0 0 0 3px #efefef, + inset 0 0 10px black, 0 0 10px rgba(0, 0, 0, 0.2); + } - - + + diff --git a/03 - CSS Variables/index-FINISHED.html b/03 - CSS Variables/index-FINISHED.html index 2f0d1464ff..b9af630085 100644 --- a/03 - CSS Variables/index-FINISHED.html +++ b/03 - CSS Variables/index-FINISHED.html @@ -1,76 +1,95 @@ - - - Scoped CSS Variables and JS - - -

Update CSS Variables with JS

- -
- - - - - - - - -
- - - - - - - - - + body { + text-align: center; + background: #193549; + color: white; + font-family: "helvetica neue", sans-serif; + font-weight: 100; + font-size: 50px; + } + + .controls { + margin-bottom: 50px; + } + + input { + width: 100px; + } + + + + diff --git a/03 - CSS Variables/index-START.html b/03 - CSS Variables/index-START.html index 6b9b539c09..2908a87f99 100644 --- a/03 - CSS Variables/index-START.html +++ b/03 - CSS Variables/index-START.html @@ -1,51 +1,79 @@ - - - Scoped CSS Variables and JS - - -

Update CSS Variables with JS

+ + + Scoped CSS Variables and JS + + +

Update CSS Variables with JS

-
- - +
+ + - - + + - - -
+ + +
- + - + .controls { + margin-bottom: 50px; + } - + input { + width: 100px; + } + - + + diff --git a/03 - CSS Variables/variables.js b/03 - CSS Variables/variables.js new file mode 100644 index 0000000000..8aeb2e72d2 --- /dev/null +++ b/03 - CSS Variables/variables.js @@ -0,0 +1,16 @@ +// overly complicated destructuring but YOLO :poop: +const updateVariable = ({ + target: { + name, + value, + dataset: { sizing: units = '' }, + }, +}) => { + const root = document.documentElement; + root.style.setProperty(`--${name}`, `${value}${units}`); +}; + +const inputs = document.querySelectorAll('.controls input'); +inputs.forEach((input) => { + input.addEventListener('input', updateVariable); +}); diff --git a/04 - Array Cardio Day 1/arrays.js b/04 - Array Cardio Day 1/arrays.js new file mode 100644 index 0000000000..d57c784382 --- /dev/null +++ b/04 - Array Cardio Day 1/arrays.js @@ -0,0 +1,134 @@ +// Get your shorts on - this is an array workout! +// ## Array Cardio Day 1 + +// Some data we can work with + +const inventors = [ + { first: 'Albert', last: 'Einstein', year: 1879, passed: 1955 }, + { first: 'Isaac', last: 'Newton', year: 1643, passed: 1727 }, + { first: 'Galileo', last: 'Galilei', year: 1564, passed: 1642 }, + { first: 'Marie', last: 'Curie', year: 1867, passed: 1934 }, + { first: 'Johannes', last: 'Kepler', year: 1571, passed: 1630 }, + { first: 'Nicolaus', last: 'Copernicus', year: 1473, passed: 1543 }, + { first: 'Max', last: 'Planck', year: 1858, passed: 1947 }, + { first: 'Katherine', last: 'Blodgett', year: 1898, passed: 1979 }, + { first: 'Ada', last: 'Lovelace', year: 1815, passed: 1852 }, + { first: 'Sarah E.', last: 'Goode', year: 1855, passed: 1905 }, + { first: 'Lise', last: 'Meitner', year: 1878, passed: 1968 }, + { first: 'Hanna', last: 'Hammarström', year: 1829, passed: 1909 }, +]; + +// Array.prototype.filter() +// 1. Filter the list of inventors for those who were born in the 1500's +const cqs = inventors.filter((item) => item.year < 1600 && item.year >= 1500); +console.table(cqs); + +// Array.prototype.map() +// 2. Give us an array of the inventors first and last names +const names = inventors.map((item) => `${item.first} ${item.last}`); +console.table(names); + +// Array.prototype.sort() +// 3. Sort the inventors by birthdate, oldest to youngest +const oldest = [...inventors].sort((a, b) => a.year - b.year); +console.table(oldest); + +// Array.prototype.reduce() +// 4. How many years did all the inventors live all together? +const totalYears = inventors.reduce( + (acc, item) => acc + item.passed - item.year, + 0 +); +console.table(totalYears); + +// 5. Sort the inventors by years lived +const longevity = [...inventors].sort((a, b) => { + return a.passed - a.year - (b.passed - b.year); +}); +console.log(longevity); + +// 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 nodes = Array.from(document.querySelectorAll('.mw-category li a')); + const result = nodes + .filter((node) => node.textContent.includes('de')) + .map((node) => node.textContent); + console.log(result); +*/ + +// 7. sort Exercise +// Sort the people alphabetically by last name +const people = [ + 'Bernhard, Sandra', + 'Bethea, Erin', + 'Becker, Carl', + 'Bentsen, Lloyd', + 'Beckett, Samuel', + 'Blake, William', + 'Berger, Ric', + 'Beddoes, Mick', + 'Beethoven, Ludwig', + 'Belloc, Hilaire', + 'Begin, Menachem', + 'Bellow, Saul', + 'Benchley, Robert', + 'Blair, Robert', + 'Benenson, Peter', + 'Benjamin, Walter', + 'Berlin, Irving', + 'Benn, Tony', + 'Benson, Leana', + 'Bent, Silas', + 'Berle, Milton', + 'Berry, Halle', + 'Biko, Steve', + 'Beck, Glenn', + 'Bergman, Ingmar', + 'Black, Elk', + 'Berio, Luciano', + 'Berne, Eric', + 'Berra, Yogi', + 'Berry, Wendell', + 'Bevan, Aneurin', + 'Ben-Gurion, David', + 'Bevel, Ken', + 'Biden, Joseph', + 'Bennington, Chester', + 'Bierce, Ambrose', + 'Billings, Josh', + 'Birrell, Augustine', + 'Blair, Tony', + 'Beecher, Henry', + 'Biondo, Frank', +]; +const lastNames = [...people].sort((a, b) => { + const aLast = a.split(',')[0]; + const bLast = b.split(',')[0]; + return aLast < bLast ? -1 : 1; +}); +console.table(lastNames); + +// 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 totes = data.reduce((acc, item) => { + acc[item] = (acc[item] ?? 0) + 1; + return acc; +}, {}); +console.table(totes); diff --git a/04 - Array Cardio Day 1/index-FINISHED.html b/04 - Array Cardio Day 1/index-FINISHED.html index d1f6ce33d6..0dec0671e1 100644 --- a/04 - Array Cardio Day 1/index-FINISHED.html +++ b/04 - Array Cardio Day 1/index-FINISHED.html @@ -1,112 +1,167 @@ - - - Array Cardio 💪 - - -

Psst: have a look at the JavaScript Console 💁

- - + + + Array Cardio 💪 + + +

Psst: have a look at the JavaScript Console 💁

+ + diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index 21bec96e8c..f993d491c3 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -1,65 +1,11 @@ - - - Array Cardio 💪 - - -

Psst: have a look at the JavaScript Console 💁

- - + + + Array Cardio 💪 + + +

Psst: have a look at the JavaScript Console 💁

+ + diff --git a/05 - Flex Panel Gallery/flex.js b/05 - Flex Panel Gallery/flex.js new file mode 100644 index 0000000000..8f41872713 --- /dev/null +++ b/05 - Flex Panel Gallery/flex.js @@ -0,0 +1,15 @@ +const panels = document.querySelectorAll('.panels .panel'); + +function toggleOpen() { + this.classList.toggle('open'); +} +function toggleActive(e) { + if (e.propertyName === 'flex-grow') { + this.classList.toggle('open-active'); + } +} + +panels.forEach((panel) => { + panel.addEventListener('click', toggleOpen); + panel.addEventListener('transitionend', toggleActive); +}) diff --git a/05 - Flex Panel Gallery/index-FINISHED.html b/05 - Flex Panel Gallery/index-FINISHED.html index bfa64d6be3..f2dd2ce3af 100644 --- a/05 - Flex Panel Gallery/index-FINISHED.html +++ b/05 - Flex Panel Gallery/index-FINISHED.html @@ -1,147 +1,169 @@ - - - Flex Panels 💪 - - - - + .panel p:nth-child(2) { + font-size: 4em; + } -
-
-

Hey

-

Let's

-

Dance

-
-
-

Give

-

Take

-

Receive

-
-
-

Experience

-

It

-

Today

-
-
-

Give

-

All

-

You can

-
-
-

Life

-

In

-

Motion

-
-
+ .panel.open { + flex: 5; + font-size: 40px; + } - + function toggleActive(e) { + console.log(e.propertyName); + if (e.propertyName.includes("flex")) { + this.classList.toggle("open-active"); + } + } - + panels.forEach((panel) => panel.addEventListener("click", toggleOpen)); + panels.forEach((panel) => + panel.addEventListener("transitionend", toggleActive) + ); + + diff --git a/05 - Flex Panel Gallery/index-START.html b/05 - Flex Panel Gallery/index-START.html index 71d1c26f00..0d667da499 100644 --- a/05 - Flex Panel Gallery/index-START.html +++ b/05 - Flex Panel Gallery/index-START.html @@ -1,114 +1,45 @@ - - - Flex Panels 💪 - - - - - - -
-
-

Hey

-

Let's

-

Dance

+ + + Flex Panels 💪 + + + + + +
+
+

Hey

+

Let's

+

Dance

+
+
+

Give

+

Take

+

Receive

+
+
+

Experience

+

It

+

Today

+
+
+

Give

+

All

+

You can

+
+
+

Life

+

In

+

Motion

+
-
-

Give

-

Take

-

Receive

-
-
-

Experience

-

It

-

Today

-
-
-

Give

-

All

-

You can

-
-
-

Life

-

In

-

Motion

-
-
- - - - - + + diff --git a/05 - Flex Panel Gallery/style.css b/05 - Flex Panel Gallery/style.css new file mode 100644 index 0000000000..f7e334d8c3 --- /dev/null +++ b/05 - Flex Panel Gallery/style.css @@ -0,0 +1,97 @@ +html { + box-sizing: border-box; + background: #ffc600; + font-family: "helvetica neue"; + font-size: 20px; + font-weight: 200; +} + +body { + margin: 0; +} + +*, +*:before, +*:after { + box-sizing: inherit; +} + +.panels { + min-height: 100vh; + overflow: hidden; + display: flex; +} + +.panel { + background: #6b0f9c; + box-shadow: inset 0 0 0 5px rgba(255, 255, 255, 0.1); + color: white; + text-align: center; + align-items: center; + /* Safari transitionend event.propertyName === flex */ + /* Chrome + FF transitionend event.propertyName === flex-grow */ + 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), background 0.2s; + font-size: 20px; + background-size: cover; + background-position: center; + flex: 1; + display: flex; + flex-direction: column; +} + +.panel1 { + background-image: url(https://source.unsplash.com/gYl-UtwNg_I/1500x1500); +} +.panel2 { + background-image: url(https://source.unsplash.com/rFKUFzjPYiQ/1500x1500); +} +.panel3 { + background-image: url(https://images.unsplash.com/photo-1465188162913-8fb5709d6d57?ixlib=rb-0.3.5&q=80&fm=jpg&crop=faces&cs=tinysrgb&w=1500&h=1500&fit=crop&s=967e8a713a4e395260793fc8c802901d); +} +.panel4 { + background-image: url(https://source.unsplash.com/ITjiVXcwVng/1500x1500); +} +.panel5 { + background-image: url(https://source.unsplash.com/3MNzGlQM7qs/1500x1500); +} + +/* Flex Children */ +.panel > * { + margin: 0; + width: 100%; + transition: transform 0.5s; + flex: 1 0 auto; + display: flex; + justify-content: center; + align-items: center; +} + +.panel p { + text-transform: uppercase; + font-family: "Amatic SC", cursive; + text-shadow: 0 0 4px rgba(0, 0, 0, 0.72), 0 0 14px rgba(0, 0, 0, 0.45); + font-size: 2em; +} + +.panel p:first-child { + transform: translateY(-100%); +} +.panel.open-active p:first-child { + transform: translateY(0); +} +.panel p:last-child { + transform: translateY(100%); +} +.panel.open-active p:last-child { + transform: translateY(0); +} + +.panel p:nth-child(2) { + font-size: 4em; +} + +.panel.open { + font-size: 40px; + flex: 5; +} diff --git a/06 - Type Ahead/index-FINISHED.html b/06 - Type Ahead/index-FINISHED.html index 5902b43936..5b6e684322 100644 --- a/06 - Type Ahead/index-FINISHED.html +++ b/06 - Type Ahead/index-FINISHED.html @@ -1,61 +1,68 @@ - - - Type Ahead 👀 - - - + + + Type Ahead 👀 + + + +
+ +
    +
  • Filter for a city
  • +
  • or a state
  • +
+
+ + searchInput.addEventListener("change", displayMatches); + searchInput.addEventListener("keyup", displayMatches); + diff --git a/06 - Type Ahead/index-START.html b/06 - Type Ahead/index-START.html index 109c90fb36..e464081488 100644 --- a/06 - Type Ahead/index-START.html +++ b/06 - Type Ahead/index-START.html @@ -1,22 +1,18 @@ - - - Type Ahead 👀 - - - - -
- -
    -
  • Filter for a city
  • -
  • or a state
  • -
-
- - + + + Type Ahead 👀 + + + +
+ +
    +
  • Filter for a city
  • +
  • or a state
  • +
+
+ + diff --git a/06 - Type Ahead/style.css b/06 - Type Ahead/style.css index 0c8c74e01b..884512e68c 100644 --- a/06 - Type Ahead/style.css +++ b/06 - Type Ahead/style.css @@ -1,12 +1,14 @@ html { box-sizing: border-box; background: #ffc600; - font-family: 'helvetica neue'; + font-family: "helvetica neue"; font-size: 20px; font-weight: 200; } -*, *:before, *:after { +*, +*:before, +*:after { box-sizing: inherit; } @@ -24,7 +26,7 @@ input.search { margin: 0; text-align: center; outline: 0; - border: 10px solid #F7F7F7; + border: 10px solid #f7f7f7; width: 120%; left: -10%; position: relative; @@ -45,7 +47,7 @@ input.search { .suggestions li { background: white; list-style: none; - border-bottom: 1px solid #D8D8D8; + border-bottom: 1px solid #d8d8d8; box-shadow: 0 0 10px rgba(0, 0, 0, 0.14); margin: 0; padding: 20px; @@ -57,12 +59,12 @@ input.search { .suggestions li:nth-child(even) { transform: perspective(100px) rotateX(3deg) translateY(2px) scale(1.001); - background: linear-gradient(to bottom, #ffffff 0%,#EFEFEF 100%); + background: linear-gradient(to bottom, #ffffff 0%, #efefef 100%); } .suggestions li:nth-child(odd) { transform: perspective(100px) rotateX(-3deg) translateY(3px); - background: linear-gradient(to top, #ffffff 0%,#EFEFEF 100%); + background: linear-gradient(to top, #ffffff 0%, #efefef 100%); } span.population { diff --git a/06 - Type Ahead/type.js b/06 - Type Ahead/type.js new file mode 100644 index 0000000000..fe51f8b528 --- /dev/null +++ b/06 - Type Ahead/type.js @@ -0,0 +1,64 @@ +const debounce = (fn, delay) => { + let timer = null; + return (...args) => { + clearTimeout(timer); + timer = setTimeout(() => fn(...args), delay); + }; +}; + +const formatNumber = (num) => + num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); + +const endpoint = + 'https://gist.githubusercontent.com/Miserlou/c5cd8364bf9b2420bb29/raw/2bf258763cdddd704f8ffd3ea9a3e81d25e2c6f6/cities.json'; + +const cities = []; + +fetch(endpoint) + .then((resp) => resp.json()) + .then((data) => cities.push(...data)); + +const findMatches = async (input) => { + const cities = []; + await fetch(endpoint) + .then((res) => res.json()) + .then((data) => { + cities.push(...data); + }); + + const pattern = new RegExp(input, 'gi'); + return cities.filter( + (data) => data.city.match(pattern) || data.state.match(pattern) + ); +}; + +const displayMatches = async (e) => { + const input = e.target.value; + console.log('input: %s', input); + const matches = await findMatches(input, cities); + const pattern = new RegExp(input, 'gi'); + suggestions.innerHTML = matches + .map((data) => { + const city = data.city.replace( + pattern, + `${input}` + ); + const state = data.state.replace( + pattern, + `${input}` + ); + const population = formatNumber(data.population); + return ` +
  • + ${city}, ${state} + ${population} +
  • + `; + }) + .join(''); +}; + +const searchInput = document.querySelector('.search-form .search'); +const suggestions = document.querySelector('.search-form .suggestions'); + +searchInput.addEventListener('input', debounce(displayMatches, 400)); diff --git a/07 - Array Cardio Day 2/array.js b/07 - Array Cardio Day 2/array.js new file mode 100644 index 0000000000..52d10b0606 --- /dev/null +++ b/07 - Array Cardio Day 2/array.js @@ -0,0 +1,42 @@ +// ## Array Cardio Day 2 + +const people = [ + { name: 'Wes', year: 1988 }, + { name: 'Kait', year: 1986 }, + { name: 'Irv', year: 1970 }, + { name: 'Lux', year: 2015 }, +]; + +const comments = [ + { text: 'Love this!', id: 523423 }, + { text: 'Super good', id: 823423 }, + { text: 'You are the best', id: 2039842 }, + { text: 'Ramen is my fav food ever', id: 123523 }, + { text: 'Nice Nice Nice!', id: 542328 }, +]; + +// Some and Every Checks +// Array.prototype.some() // is at least one person 19 or older? +const isAdult = people.some((p) => new Date().getFullYear() - p.year >= 19); +console.log({ isAdult }); +// Array.prototype.every() // is everyone 19 or older? +const allAdults = people.every((p) => new Date().getFullYear() - p.year >= 19); +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 myComment = comments.find((comment) => comment.id === 823423); +console.log({ myComment }); + +// Array.prototype.findIndex() +// Find the comment with this ID +// delete the comment with the ID of 823423 +const myID = comments.findIndex(comment => comment.id === 823423) +console.log({myID}) + +console.table([ + ...comments.slice(0, myID), + ...comments.slice(myID + 1) +]) + diff --git a/07 - Array Cardio Day 2/index-FINISHED.html b/07 - Array Cardio Day 2/index-FINISHED.html index 24efbf91b0..0f85a3a7a1 100644 --- a/07 - Array Cardio Day 2/index-FINISHED.html +++ b/07 - Array Cardio Day 2/index-FINISHED.html @@ -1,68 +1,70 @@ - - - Array Cardio 💪💪 - - -

    Psst: have a look at the JavaScript Console 💁

    - - + const newComments = [ + ...comments.slice(0, index), + ...comments.slice(index + 1), + ]; + + diff --git a/07 - Array Cardio Day 2/index-START.html b/07 - Array Cardio Day 2/index-START.html index 969566ff78..e3f986b6e9 100644 --- a/07 - Array Cardio Day 2/index-START.html +++ b/07 - Array Cardio Day 2/index-START.html @@ -1,41 +1,11 @@ - - - Array Cardio 💪💪 - - -

    Psst: have a look at the JavaScript Console 💁

    - - + + + Array Cardio 💪💪 + + +

    Psst: have a look at the JavaScript Console 💁

    + + diff --git a/09 - Dev Tools Domination/devtools.js b/09 - Dev Tools Domination/devtools.js new file mode 100644 index 0000000000..c6e64d5bfe --- /dev/null +++ b/09 - Dev Tools Domination/devtools.js @@ -0,0 +1,65 @@ +const dogs = [ + { name: 'Snickers', age: 2 }, + { name: 'hugo', age: 8 }, +]; + +function makeGreen() { + const p = document.querySelector('p'); + p.style.color = '#BADA55'; + p.style.fontSize = '50px'; +} + +// Regular +console.log('this is a message'); + +// Interpolated +console.log('Now is %s', new Date().toLocaleString()); +console.log(`Now is ${new Date().toLocaleString()}`); + +// Styled +console.log( + '%c check it!', + 'font-size: 50px;font-style:italic; text-shadow: 4px 4px 6px #bada55' +); + +// warning! +console.warn('this is a warning!'); + +// Error :| +console.error('this is an error'); + +// Info +console.info('this is some info') + +// Testing +console.assert(3 === 3, "this is wrong") + +// clearing +console.clear() + +// Viewing DOM Elements +const p = document.querySelector('p'); +console.log(p); +console.dir(p); +console.clear(); + +// Grouping together +dogs.forEach(dog => { + console.groupCollapsed(`${dog.name}`) + console.log(`this is ${dog.name}`) + console.log(`he is ${dog.age} years old`) + console.log(`that's ${dog.age * 7} dog years`) + console.groupEnd(`${dog.name}`) +}) + + +// counting + +// timing +console.time('fetch'); +fetch('https://api.github.com/users/ultranaut') + .then(res => res.json()) + .then(data => { + console.timeEnd('fetch'); + console.log(data) + }) diff --git a/09 - Dev Tools Domination/index-FINISHED.html b/09 - Dev Tools Domination/index-FINISHED.html index 55cd3a2f42..b7d00d4c2b 100644 --- a/09 - Dev Tools Domination/index-FINISHED.html +++ b/09 - Dev Tools Domination/index-FINISHED.html @@ -1,89 +1,90 @@ - - - Console Tricks! - - - -

    ×BREAK×DOWN×

    - - - + // counting + + console.count("Wes"); + console.count("Wes"); + console.count("Steve"); + console.count("Steve"); + console.count("Wes"); + console.count("Steve"); + console.count("Wes"); + console.count("Steve"); + console.count("Steve"); + console.count("Steve"); + console.count("Steve"); + console.count("Steve"); + + // timing + console.time("fetching data"); + fetch("https://api.github.com/users/wesbos") + .then((data) => data.json()) + .then((data) => { + console.timeEnd("fetching data"); + console.log(data); + }); + + console.table(dogs); + + diff --git a/09 - Dev Tools Domination/index-START.html b/09 - Dev Tools Domination/index-START.html index 196fffd719..5ceea3575f 100644 --- a/09 - Dev Tools Domination/index-START.html +++ b/09 - Dev Tools Domination/index-START.html @@ -1,46 +1,12 @@ - - - Console Tricks! - - - -

    ×BREAK×DOWN×

    - - - + + + Console Tricks! + + +

    ×BREAK×DOWN×

    + + + diff --git a/10 - Hold Shift and Check Checkboxes/check.js b/10 - Hold Shift and Check Checkboxes/check.js new file mode 100644 index 0000000000..0486c05b7c --- /dev/null +++ b/10 - Hold Shift and Check Checkboxes/check.js @@ -0,0 +1,32 @@ +const checkboxes = document.querySelectorAll('.inbox input[type=checkbox]'); + +let prevChecked = null; + +const handleCheck = (e) => { + const currChecked = e.target; + // we only need to do anything if the shift key is pressed + if (e.shiftKey) { + let inRange = false; + + // if we haven't actually done anything yet, set prevChecked to first one + if (!prevChecked) { + prevChecked = checkboxes[0]; + } + + checkboxes.forEach((checkbox) => { + if (checkbox === prevChecked || checkbox === currChecked) { + inRange = !inRange; + } + if (inRange) { + checkbox.checked = true; + } + }) + + } + + prevChecked = currChecked; +} + +checkboxes.forEach((checkbox) => { + checkbox.addEventListener('click', handleCheck); +}) diff --git a/10 - Hold Shift and Check Checkboxes/index-FINISHED.html b/10 - Hold Shift and Check Checkboxes/index-FINISHED.html index d967b249cd..0de57dd289 100644 --- a/10 - Hold Shift and Check Checkboxes/index-FINISHED.html +++ b/10 - Hold Shift and Check Checkboxes/index-FINISHED.html @@ -1,130 +1,132 @@ - - - Hold Shift to Check Multiple Checkboxes - - - - -
    -
    - -

    This is an inbox layout.

    -
    -
    - -

    Check one item

    -
    -
    - -

    Hold down your Shift key

    +
    +
    + +

    This is an inbox layout.

    +
    +
    + +

    Check one item

    +
    +
    + +

    Hold down your Shift key

    +
    +
    + +

    Check a lower item

    +
    +
    + +

    Everything in between should also be set to checked

    +
    +
    + +

    Try do it without any libraries

    +
    +
    + +

    Just regular JavaScript

    +
    +
    + +

    Good Luck!

    +
    +
    + +

    Don't forget to tweet your result!

    +
    -
    - -

    Check a lower item

    -
    -
    - -

    Everything in between should also be set to checked

    -
    -
    - -

    Try do it without any libraries

    -
    -
    - -

    Just regular JavaScript

    -
    -
    - -

    Good Luck!

    -
    -
    - -

    Don't forget to tweet your result!

    -
    -
    - - + checkboxes.forEach((checkbox) => + checkbox.addEventListener("click", handleCheck) + ); + + diff --git a/10 - Hold Shift and Check Checkboxes/index-START.html b/10 - Hold Shift and Check Checkboxes/index-START.html index 4fd2936ddc..e589813775 100644 --- a/10 - Hold Shift and Check Checkboxes/index-START.html +++ b/10 - Hold Shift and Check Checkboxes/index-START.html @@ -1,101 +1,99 @@ - - - Hold Shift to Check Multiple Checkboxes - - - - -
    -
    - -

    This is an inbox layout.

    -
    -
    - -

    Check one item

    -
    -
    - -

    Hold down your Shift key

    -
    -
    - -

    Check a lower item

    -
    -
    - -

    Everything in between should also be set to checked

    -
    -
    - -

    Try to do it without any libraries

    -
    -
    - -

    Just regular JavaScript

    -
    -
    - -

    Good Luck!

    -
    -
    - -

    Don't forget to tweet your result!

    +
    +
    + +

    This is an inbox layout.

    +
    +
    + +

    Check one item

    +
    +
    + +

    Hold down your Shift key

    +
    +
    + +

    Check a lower item

    +
    +
    + +

    Everything in between should also be set to checked

    +
    +
    + +

    Try to do it without any libraries

    +
    +
    + +

    Just regular JavaScript

    +
    +
    + +

    Good Luck!

    +
    +
    + +

    Don't forget to tweet your result!

    +
    -
    - - + +