Created
March 29, 2020 12:37
-
-
Save genert/dc9532a897443b56271e20b63eb56824 to your computer and use it in GitHub Desktop.
Lumovest - get course total time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function display (seconds) { | |
const format = val => `0${Math.floor(val)}`.slice(-2) | |
const hours = seconds / 3600 | |
const minutes = (seconds % 3600) / 60 | |
return [hours, minutes, seconds % 60].map(format).join(':') | |
} | |
// The magic | |
display([...document.querySelectorAll('.lesson-time')]. | |
map((el) => el.textContent.split(':'). | |
reduce((acc,time) => (60 * acc) + +time)). | |
filter(Number). | |
reduce((a,b) => a + b, 0)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment