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
getRandomProgress = () => { | |
let secs = 0; // How many seconds to wait | |
let perc = 0; // How much percentage to update | |
let func = () => { | |
if (perc < 100 ) { // Exit the loop if we reached 100 | |
perc = Math.min((perc + Math.floor(Math.random() * 40)), 100); //Get the random percentage, make sure it is less than 100 | |
secs += Math.ceil(Math.random()*2); // Get random Time | |
(function(_perc, _secs) { | |
return setTimeout(function(){/*update dom here*/console.log(_perc, _secs)}, _secs*1000); | |
})(perc, secs) |