Skip to content

Instantly share code, notes, and snippets.

@Naoray
Created July 8, 2016 10:47
Show Gist options
  • Save Naoray/567de3d395c93485d790f9d3a2c1977f to your computer and use it in GitHub Desktop.
Save Naoray/567de3d395c93485d790f9d3a2c1977f to your computer and use it in GitHub Desktop.
var time = '';
var hour = 0;
var min = 0;
var sec = 0;
$.each($('.Lesson-List__length'), function(i, el) {
min += parseInt($(el).text().split(':')[0]);
sec += parseInt($(el).text().split(':')[1]);
if(sec >= 60) {
min += parseInt(sec/60);
sec %= 60;
}
if(min >= 60) {
hour += parseInt(min/60);
min %= 60;
}
});
time = 'It will take me ' + ((hour.toString().length == 1) ? '0' + hour : hour) + ':' + ((min.toString().length == 1) ? '0' + min : min) + ':' + ((sec.toString().length == 1) ? '0' + sec: sec) + ' hours to watch all those videos!';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment