-
Notifications
You must be signed in to change notification settings - Fork 0
/
arrow-func-ex-1.html
42 lines (38 loc) · 1.19 KB
/
arrow-func-ex-1.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
<!DOCTYPE html>
<html>
<head>
<title>Exercise 1</title>
</head>
<body>
<ul>
<li date-time="9:10">Flexbox Video</li>
<li date-time="3:20">Flexbox Video</li>
<li date-time="3:15">Redux Video</li>
<li date-time="3:15">React Video</li>
<li date-time="3:15">Flexbox Video</li>
<li date-time="3:15">React Native Video</li>
<li date-time="6:26">Flexbox Video</li>
<li date-time="3:15">CSS Video</li>
<li date-time="3:15">ES6 Video</li>
<li date-time="3:15">ES2016 Video</li>
<li date-time="3:00">Flexbox Video</li>
<li date-time="3:15">Grunt Video</li>
<li date-time="3:15">Webpack Video</li>
<li date-time="3:15">AWS Video</li>
<li date-time="10:15">Flexbox Video</li>
</ul>
<script>
const listItems = Array.from(document.querySelectorAll('li[date-time]'));
// console.log(listItems);
const flexBoxVideosTimes = listItems
.filter(item => item.innerText.includes('Flexbox'))
.map(item => item.getAttribute('date-time'))
.map(time => {
[mins, seconds] = time.split(':', 2).map(part => parseInt(part));
return (mins * 60) + seconds;
})
.reduce((totalTime, currentValue) => totalTime + currentValue, 0);
console.log(flexBoxVideosTimes);
</script>
</body>
</html>