Skip to content

Commit 6fbb051

Browse files
committed
four complete
1 parent 2b8b281 commit 6fbb051

2 files changed

Lines changed: 106 additions & 0 deletions

File tree

03 - CSS Variables/index-START.html

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,21 @@ <h2>Update CSS Variables with <span class='hl'>JS</span></h2>
2121
<img src="https://source.unsplash.com/7bwQXzbF6KE/800x500">
2222

2323
<style>
24+
:root {
25+
--base: #373737;
26+
--spacing: 10px;
27+
--blur: 10px;
28+
}
29+
30+
img{
31+
padding: var(--spacing);
32+
background: var(--base);
33+
filter: blur(var(--blur));
34+
}
35+
36+
.hl{
37+
color: var(--base);
38+
}
2439

2540
/*
2641
misc styles, nothing to do with CSS variables
@@ -48,6 +63,20 @@ <h2>Update CSS Variables with <span class='hl'>JS</span></h2>
4863
</style>
4964

5065
<script>
66+
const inputs = document.querySelectorAll('.controls input');
67+
68+
function handleUpdate(){
69+
// console.log(this.value);
70+
console.log(this.dataset);
71+
const suffix = this.dataset.sizing || '';
72+
/*so you can take the px to the end of the new value below*/
73+
document.documentElement.style.setProperty(`--${this.name}`, this.value + suffix)
74+
}
75+
76+
inputs.forEach(input => input.addEventListener('change', handleUpdate));
77+
/*does not change for when you drag back and forth, so add mousemove below*/
78+
inputs.forEach(input => input.addEventListener('mousemove', handleUpdate));
79+
5180
</script>
5281

5382
</body>

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

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,29 +33,106 @@
3333

3434
// Array.prototype.filter()
3535
// 1. Filter the list of inventors for those who were born in the 1500's
36+
const fifteen = inventors.filter(inventor =>
37+
inventor.year >= 1500 && inventor.year < 1600)
38+
console.table(fifteen);
3639

3740
// Array.prototype.map()
3841
// 2. Give us an array of the inventors' first and last names
42+
//will always return the same number of items as you give it
43+
// const fullNames = inventors.map(inventor =>
44+
// inventor.first + ' ' + inventor.last);
45+
// console.log(fullNames);
46+
// //or
47+
const fullNames = inventors.map(inventor =>
48+
`${inventor.first} ${inventor.last}`);
49+
console.log(fullNames);
3950

4051
// Array.prototype.sort()
4152
// 3. Sort the inventors by birthdate, oldest to youngest
53+
//you get two items and you have to sort those two
54+
55+
// const ordered = inventors.sort(function(a, b){
56+
// if (a.year > b.year){
57+
// return 1;
58+
// } else {
59+
// return -1;
60+
// }
61+
// })
62+
63+
// console.table(ordered)
64+
//or
65+
66+
const ordered = inventors.sort((a, b) =>
67+
a.year > b.year ? 1 : -1);
68+
69+
console.table(ordered);
4270

4371
// Array.prototype.reduce()
4472
// 4. How many years did all the inventors live?
73+
const totalYears = inventors.reduce((total, inventor) => {
74+
return total + (inventor.passed - inventor.year);
75+
//to get the number of years they lived
76+
}, 0)
77+
console.log(totalYears);
4578

4679
// 5. Sort the inventors by years lived
80+
const oldest = inventors.sort(function(a, b){
81+
const lastGuy = a.passed - a.year;
82+
const nextGuy = b.passed - b.year;
83+
return lastGuy > nextGuy ? -1 : 1;
84+
// if(lastGuy > nextGuy){
85+
// return -1;
86+
// } else {
87+
// return 1;
88+
// }
89+
})
90+
console.table(oldest);
4791

4892
// 6. create a list of Boulevards in Paris that contain 'de' anywhere in the name
4993
// https://en.wikipedia.org/wiki/Category:Boulevards_in_Paris
5094

95+
//IN CONSOLE OF WIKI PAGE^
96+
//dev tools
97+
//
98+
// const category = document.querySelector('.mw-category');
99+
// const links = Array.from(category.querySelectorAll('a'));
100+
// //convert list of links to list of names
101+
// //array.from will make it into an array from the nodelist
102+
103+
// const de = links
104+
// .map(link => link.textContent)
105+
// //will give the text inside of each link
106+
// .filter(streetName => streetName.includes('de'));
107+
// //will filter them out
51108

52109
// 7. sort Exercise
53110
// Sort the people alphabetically by last name
111+
const alpha = people.sort((lastOne, nextOne) => {
112+
// console.log(lastOne);
113+
const [last, first] = lastOne.split(', ');
114+
const [lastN, firstN] = nextOne.split(', ');
115+
// console.log(last, first);
116+
// console.log(lastN, firstN);
117+
return last > lastN ? 1 : -1;
118+
})
119+
console.log(alpha);
54120

55121
// 8. Reduce Exercise
56122
// Sum up the instances of each of these
57123
const data = ['car', 'car', 'truck', 'truck', 'bike', 'walk', 'car', 'van', 'bike', 'walk', 'car', 'van', 'car', 'truck' ];
58124

125+
const transportation = data.reduce(function(obj, item) {
126+
if (!obj[item]){
127+
obj[item] = 0;
128+
}
129+
130+
// console.log(item);
131+
obj[item] ++;
132+
return obj;
133+
}, {})
134+
console.log(transportation);
135+
59136
</script>
60137
</body>
61138
</html>

0 commit comments

Comments
 (0)