Beginning with node.js, I try to invoke a function after a random amount of time.
Why does this not work :
function main() {
console.log('*** START ***');
}
function blink() {
console.log('*** BLINK ***');
}
main();
var delay = Number(Math.random(1000, 10000));
setTimeout(blink, delay);
If I replace the random generated number with a static one, it works :
function main() {
console.log('*** START ***');
}
function blink() {
console.log('*** BLINK ***');
}
main();
setTimeout(blink, 3000);
Where did I go wrong ?