Skip to content

Commit b5904ec

Browse files
committed
Finished day 18
1 parent 0824610 commit b5904ec

File tree

3 files changed

+23
-208
lines changed

3 files changed

+23
-208
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const timeNodes = Array.from(document.querySelectorAll('[data-time]'));
2+
3+
4+
//try putting this all in one reduce;
5+
6+
7+
const seconds = timeNodes
8+
.map(node => node.dataset.time)
9+
.map(timeCode => {
10+
const [mins, secs] = timeCode.split(':').map(parseFloat);
11+
return (mins * 60) + secs;
12+
})
13+
.reduce((total, vidSeconds) => total + vidSeconds)
14+
15+
let secondsLeft = seconds;
16+
const hours = Math.floor(secondsLeft / 3600);
17+
secondsLeft = secondsLeft % 3600;
18+
19+
const mins = Math.floor(secondsLeft/ 60);
20+
secondsLeft = secondsLeft % 60;
21+
22+
console.log(hours, mins, secondsLeft);

18 - Adding Up Times with Reduce/index-FINISHED.html

Lines changed: 0 additions & 207 deletions
This file was deleted.

18 - Adding Up Times with Reduce/index-START.html renamed to 18 - Adding Up Times with Reduce/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@
181181
Video 58
182182
</li>
183183

184-
<script>
184+
<script src="adding.js">
185185
</script>
186186
</body>
187187
</html>

0 commit comments

Comments
 (0)