We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent aea0dce commit 4cedce2Copy full SHA for 4cedce2
1 file changed
18 - Adding Up Times with Reduce/index-START.html
@@ -182,6 +182,18 @@
182
</li>
183
</ul>
184
<script>
185
+ const videos = Array.from(document.querySelectorAll('.videos > li'))
186
+ const videoTimes = videos.map((video) => {
187
+ return video.dataset.time
188
+ })
189
+
190
+ const totalTime = videoTimes.reduce((sum, time) => {
191
+ const [minutes, seconds] = time.split(':')
192
+ sum += parseInt(minutes) * 60
193
+ sum += parseInt(seconds)
194
+ return sum
195
+ }, 0)
196
+ console.log(totalTime)
197
</script>
198
</body>
199
</html>
0 commit comments