Skip to content

Instantly share code, notes, and snippets.

@genert
Created March 29, 2020 12:37
Show Gist options
  • Save genert/dc9532a897443b56271e20b63eb56824 to your computer and use it in GitHub Desktop.
Save genert/dc9532a897443b56271e20b63eb56824 to your computer and use it in GitHub Desktop.
Lumovest - get course total time
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