Using setTimeout()
it is possible to launch a function at a specified time:
setTimeout(function, 60000);
But what if I would l
function random(number) {
return Math.floor(Math.random() * (number+1));
}
setInterval(() => {
const rndCol = 'rgb(' + random(255) + ',' + random(255) + ',' + random(255) + ')';//rgb value (0-255,0-255,0-255)
document.body.style.backgroundColor = rndCol;
}, 1000);
it changes background color in every 1 second (written as 1000 in JS)