Skip to content

Commit 3321f62

Browse files
Lección 18
1 parent 5f7480f commit 3321f62

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,25 @@
182182
</li>
183183
</ul>
184184
<script>
185+
const timeNodes = [...document.querySelectorAll('[data-time]')];
186+
const seconds = timeNodes
187+
.map(node => node.dataset.time)
188+
.map(timeCode => {
189+
const[mins, secs] = timeCode.split(':').map(parseFloat);
190+
return (mins * 60) + secs;
191+
console.log(mins, secs);
192+
})
193+
.reduce((total, vidSeconds) => total + vidSeconds)
194+
195+
let secondsLeft = seconds;
196+
//const hours = Math.floor(secondsLeft / 3600);
197+
const hours = parseInt(secondsLeft / 3600);
198+
const minsLeft = secondsLeft % 3600;
199+
const mins = parseInt( minsLeft / 60);
200+
const secsLeft = minsLeft % 60;
201+
//const secs = parseInt(mins / 60);
202+
//const mins = Math.floor(secondsLeft / 60);
203+
console.log(hours,mins,secsLeft);
185204
</script>
186205
</body>
187206
</html>

0 commit comments

Comments
 (0)