Skip to content

Commit f492569

Browse files
committed
work1223
work1223
1 parent afa316e commit f492569

File tree

4 files changed

+174
-5
lines changed

4 files changed

+174
-5
lines changed

07 - Array Cardio Day 2/index-START.html

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,62 @@
2626

2727
// Some and Every Checks
2828
// Array.prototype.some() // is at least one person 19 or older?
29+
const isAdult = people.some(function(person){
30+
const currentYear = (new Date()).getFullYear();
31+
if(currentYear - person.year >=19) {
32+
return true;
33+
}
34+
});
35+
console.log({isAdult});
36+
37+
//condensed way
38+
const isAdultS = people.some(person=>{
39+
const currentYear = (new Date()).getFullYear();
40+
return currentYear - person.year >=19;
41+
});
42+
console.log({isAdultS});
43+
44+
//evenmore condensed
45+
const isAdultSS = people.some(person=> ((new Date()).getFullYear())- person.year >=19);
46+
console.log({isAdultSS});
47+
48+
49+
50+
2951
// Array.prototype.every() // is everyone 19 or older?
52+
const allAdultSS = people.every(person=> ((new Date()).getFullYear())- person.year >=19);
53+
console.log({allAdultSS});
3054

3155
// Array.prototype.find()
3256
// Find is like filter, but instead returns just the one you are looking for
3357
// find the comment with the ID of 823423
58+
const comment = comments.find(function(comment){
59+
if (comment.id === 823423) {
60+
return true;
61+
}
62+
});
63+
console.log(comment);
64+
65+
//condensed
66+
const commentSS = comments.find(comment=> comment.id === 823423);
67+
console.log(commentSS);
68+
3469

3570
// Array.prototype.findIndex()
3671
// Find the comment with this ID
3772
// delete the comment with the ID of 823423
73+
const index = comments.findIndex(comment=> comment.id===823423);
74+
console.log({index});
75+
// comments.splice(index, 1);
76+
3877

78+
//instead of splice - create a new array by doing this -
79+
const newComments = [
80+
...comments.slice(0,index),
81+
...comments.slice(index+1)
82+
];
83+
console.table(comments);
84+
console.table(newComments);
3985
</script>
4086
</body>
4187
</html>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Array Cardio 💪💪</title>
6+
</head>
7+
<body>
8+
<p><em>Psst: have a look at the JavaScript Console</em> 💁</p>
9+
<script>
10+
// ## Array Cardio Day 2
11+
12+
const people = [
13+
{ name: 'Wes', year: 1988 },
14+
{ name: 'Kait', year: 1986 },
15+
{ name: 'Irv', year: 1970 },
16+
{ name: 'Lux', year: 2015 }
17+
];
18+
19+
const comments = [
20+
{ text: 'Love this!', id: 523423 },
21+
{ text: 'Super good', id: 823423 },
22+
{ text: 'You are the best', id: 2039842 },
23+
{ text: 'Ramen is my fav food ever', id: 123523 },
24+
{ text: 'Nice Nice Nice!', id: 542328 }
25+
];
26+
27+
// Some and Every Checks
28+
// Array.prototype.some() // is at least one person 19 or older?
29+
// Array.prototype.every() // is everyone 19 or older?
30+
31+
// Array.prototype.find()
32+
// Find is like filter, but instead returns just the one you are looking for
33+
// find the comment with the ID of 823423
34+
35+
// Array.prototype.findIndex()
36+
// Find the comment with this ID
37+
// delete the comment with the ID of 823423
38+
39+
</script>
40+
</body>
41+
</html>

09 - Dev Tools Domination/index-START.html

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,64 @@
1818
}
1919

2020
// Regular
21+
console.log('hello');
2122

2223
// Interpolated
23-
24+
console.log('hello i am a %s string', 'aasdf');
2425
// Styled
26+
console.log('%cI am text','font-size:50px');
2527

2628
// warning!
29+
console.warn('oh noo');
30+
2731

2832
// Error :|
33+
console.error('damn');
2934

30-
// Info
3135

32-
// Testing
36+
// Info
37+
console.info('damn');
38+
39+
// Testing - if fails, you get the error message
40+
const p = document.querySelector('p');
41+
console.assert(1===2,'not equal');
3342

34-
// clearing
43+
// clearing - clears all console entries before this.
44+
console.clear()
3545

3646
// Viewing DOM Elements
37-
47+
console.log(p);
48+
console.dir(p);
49+
3850
// Grouping together
51+
dogs.forEach(dog =>{
52+
console.groupCollapsed (`${dog.name}`);
53+
console.log(`This is ${dog.name}`);
54+
console.log(`${dog.name} is ${dog.age} in dog years`);
55+
console.groupEnd (`${dog.name}`);
56+
57+
});
58+
3959

4060
// counting
61+
console.count('david');
62+
console.count('david');
63+
console.count('david');
64+
console.count('david');
65+
console.count('Kari');
66+
console.count('Kari');
67+
4168

4269
// timing
70+
console.time('fetching data');
71+
fetch('https://api.github.com/users/wesbos')
72+
.then(data =>data.json())
73+
.then(data=>{
74+
console.timeEnd('fetching data');
75+
console.log(data)
76+
});
77+
78+
console.table(dogs);
4379

4480
</script>
4581
</body>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Console Tricks!</title>
6+
</head>
7+
<body>
8+
9+
<p onClick="makeGreen()">×BREAK×DOWN×</p>
10+
11+
<script>
12+
const dogs = [{ name: 'Snickers', age: 2 }, { name: 'hugo', age: 8 }];
13+
14+
function makeGreen() {
15+
const p = document.querySelector('p');
16+
p.style.color = '#BADA55';
17+
p.style.fontSize = '50px';
18+
}
19+
20+
// Regular
21+
22+
// Interpolated
23+
24+
// Styled
25+
26+
// warning!
27+
28+
// Error :|
29+
30+
// Info
31+
32+
// Testing
33+
34+
// clearing
35+
36+
// Viewing DOM Elements
37+
38+
// Grouping together
39+
40+
// counting
41+
42+
// timing
43+
44+
</script>
45+
</body>
46+
</html>

0 commit comments

Comments
 (0)