Skip to content

Instantly share code, notes, and snippets.

@shuantsu-zz
Last active April 26, 2021 23:57
Show Gist options
  • Save shuantsu-zz/9d0f154e83ccd4cda4f5a0f7790ea348 to your computer and use it in GitHub Desktop.
Save shuantsu-zz/9d0f154e83ccd4cda4f5a0f7790ea348 to your computer and use it in GitHub Desktop.
Alura quanto tempo a aula vai levar
const a = [];
document.querySelectorAll('.task-menu-nav-item-videoDuration').forEach((x)=>{a.push(parseInt(x.innerHTML.replace('min', '')))});
const speeds = [1, 1.2, 1.5, 2, 2.5, 3];
const total = a.reduce((x, y) => x + y);
let s = "";
for (let speed of speeds) {
const tempo = total / speed;
const minutos = Math.floor(tempo);
const segundos = (tempo % 60).toFixed(2);
s += `${speed}x => ${minutos}:${segundos}\n`;
}
alert(s);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment