-
Notifications
You must be signed in to change notification settings - Fork 5
/
cardioTwo.jade
58 lines (43 loc) · 1.5 KB
/
cardioTwo.jade
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
extends base
block vars
- var title = 'Array Cardio Two'
block styles
link(rel="stylesheet" type="text/css" href="styles/cardioTwo.css")
block body
h2 Cardio Two
p check console for values
script(type="text/javascript").
const people = [
{ name: 'Akinjide', year: 1995 },
{ 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 in my fav food ever', id: 123523 },
{ text: 'Nice Nice Nice!', id: 542328 }
]
//- Array.prototype.some()
const isAdult = people.some(person => (new Date().getFullYear()) - person.year >= 19)
//- Array.prototype.every()
const allAdult = people.every(person => (new Date().getFullYear()) - person.year >= 19)
//- Array.prototype.find()
const comment = comments.find(comment => comment.id === 823423)
//- Array.prototype.findIndex()
const index = comments.findIndex(comment => comment.id === 823423)
const newComments = [
...comments.slice(0, index),
...comments.slice(index + 1)
]
// Is at least one person 19?
console.log({isAdult})
// Is everyone 19?
console.log({allAdult})
// Find the comment with the ID of 823423
console.log(comment)
// Find and Delete the comment with ID of 824323
console.table(newComments)