Created
May 15, 2020 22:04
-
-
Save toti1212/5af42b4d29c2bdcbaabbfc068f6d652b to your computer and use it in GitHub Desktop.
Platzi courses duration
This file contains hidden or 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
const durations = document.getElementsByClassName('MaterialItem-copy-time') | |
const getCourseDuration = (durations) => { | |
let minutes = 0; | |
let seconds = 0; | |
for (i=0; i< durations.length; i++) { | |
let duration = durations[i].textContent.split('min')[0].split(":"); | |
minutes += parseInt(duration[0]) | |
seconds += parseInt(duration[1]) | |
} | |
minutes += seconds / 60 | |
return `This course takes hs ${parseInt(minutes / 60)} mins ${parseInt(minutes % 60)}` | |
} | |
getCourseDuration(durations) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment