Skip to content

Commit d98f172

Browse files
committed
wesbos#4 completed!
1 parent 894a648 commit d98f172

File tree

2 files changed

+40
-16
lines changed

2 files changed

+40
-16
lines changed

03 - CSS Variables/index-START.html

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,22 @@ <h2>Update CSS Variables with <span class='hl'>JS</span></h2>
5858
<script>
5959
let inputs = document.querySelectorAll('.controls input');
6060
let handleUpdate = (e) => {
61+
console.log(this);
6162
const suffix = this.dataset.sizing || '';
62-
let { id } = e.target;
63-
let image = document.querySelector('img');
64-
if (id === 'spacing'){
65-
image.style.setProperty('--spacing', `${this.value}${suffix}`);
66-
} else if (id === 'blur'){
67-
image.style.setProperty('--blur', `${this.value}${suffix}`);
68-
} else if (id === 'base'){
69-
image.style.setProperty('--base', `${this.value}${suffix}`);
70-
}
63+
// let { id } = e.target;
64+
// let image = document.querySelector('img');
65+
// if (id === 'spacing'){
66+
// image.style.setProperty('--spacing', `${this.value}${suffix}`);
67+
// } else if (id === 'blur'){
68+
// image.style.setProperty('--blur', `${this.value}${suffix}`);
69+
// } else if (id === 'base'){
70+
// image.style.setProperty('--base', `${this.value}${suffix}`);
71+
// }
7172

7273
}
7374

74-
inputs.forEach(input => input.addEventListener('change', handleUpdate));
75-
inputs.forEach(input => input.addEventListener('mousemove', handleUpdate));
75+
inputs.forEach(input => input.addEventListener('change', () => handleUpdate()));
76+
inputs.forEach(input => input.addEventListener('mousemove',() => handleUpdate()));
7677
</script>
7778

7879
</body>

04 - Array Cardio Day 1/index-START.html

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,52 @@
3131

3232
// Array.prototype.filter()
3333
// 1. Filter the list of inventors for those who were born in the 1500's
34-
34+
let before1500 = inventors.filter(x => x.year > 1500 && x.year < 1600);
35+
console.table(before1500)
3536
// Array.prototype.map()
3637
// 2. Give us an array of the inventors' first and last names
37-
38+
let firstAndLastNames = inventors.map(x => [x.first, x.last]);
39+
console.log(firstAndLastNames);
3840
// Array.prototype.sort()
3941
// 3. Sort the inventors by birthdate, oldest to youngest
40-
42+
let sorted = inventors.sort((a, b) => a.year > b.year ? 1 : -1);
43+
console.table(sorted);
4144
// Array.prototype.reduce()
4245
// 4. How many years did all the inventors live?
46+
let reduced = inventors.reduce((a, b) => a + (b.passed - b.year), 0);
47+
console.log(reduced);
4348

4449
// 5. Sort the inventors by years lived
45-
50+
let sortedByYearsLived = inventors.sort((a, b) => (a.passed - a.year) > (b.passed - b.year) ? 1: -1);
51+
console.table(sortedByYearsLived);
4652
// 6. create a list of Boulevards in Paris that contain 'de' anywhere in the name
4753
// https://en.wikipedia.org/wiki/Category:Boulevards_in_Paris
54+
[...document.querySelectorAll('.mw-category a')].map(node => node.innerHTML).filter(text => text.includes('de'))
55+
// nah i dont wanna get list of paris names. i'm going to instead all people with "beck" in its name
4856

57+
58+
let beckPeople = people.filter(x => x.toLowerCase().includes('beck'));
59+
console.log('beckpeople', beckPeople);
4960

5061
// 7. sort Exercise
5162
// Sort the people alphabetically by last name
63+
let sortedByLastName = people.sort();
64+
console.log('lastname sort', sortedByLastName);
65+
let sortedByFirstName = people.sort((a, b) => a.split(',')[1] > b.split(',')[1] ? 1 : -1);
66+
console.log('firstname', sortedByFirstName);
5267

5368
// 8. Reduce Exercise
5469
// Sum up the instances of each of these
5570
const data = ['car', 'car', 'truck', 'truck', 'bike', 'walk', 'car', 'van', 'bike', 'walk', 'car', 'van', 'car', 'truck' ];
56-
71+
let dataCount = data.reduce((count, curr) => {
72+
if (!count[curr]) {
73+
count[curr] = 1
74+
} else {
75+
count[curr] ++;
76+
}
77+
return count;
78+
}, {});
79+
console.table(dataCount);
5780
</script>
5881
</body>
5982
</html>

0 commit comments

Comments
 (0)