forked from wijaksanapanji/learn-javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
JohnAdemoye.html
61 lines (52 loc) · 1.47 KB
/
JohnAdemoye.html
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
59
60
61
<!DOCTYPE html>
<html>
<body>
<script>
// your code here
// 3
const actions = [
'rest and refresh',
'connect with others',
'take time to enjoy',
'share interests',
'contribute to community',
'take care of yourself',
'challenge yourself',
'reduce your stress',
'notice the here and now',
'ask for help'
];
// 4
for (let index = 0; index < actions.length; index++) {
console.log(actions[index]);
}
// 5
actions.forEach(action => console.log(action));
// 6
actions.map(
(action, index) => `${console.log('%i : %s', index, action)}`
);
actions.forEach(action => console.log(action));
// 7
actions
.filter(action => action.startsWith('c'))
.map((action, index) => console.log('%i : %s', index, action));
actions
.filter(action => action.startsWith('c'))
.forEach((action, index) => console.log('%i : %s', index, action));
// 8
const actionLetters = actions.map(
action => action.replace(/\s/g, '').length
);
console.log(actionLetters);
// 9
const sumOfLetters = actionLetters.reduce((a, b) => a + b, 0);
console.log(sumOfLetters);
// 10
const itemLessThanTen = actionLetters.findIndex(
sumOfLetter => sumOfLetter < 10
);
console.log(itemLessThanTen); // None
</script>
</body>
</html>