+ 11
Can the setInterval method still work when included inside a function?
3 Answers
+ 2
// Actually, you can. You'll just need to call the function to start.
function printWhatever() {
console.log("whatever");
}
function callPrintWhateverEachSecond() {
setInterval(printWhatever, 1000);
}
callPrintWhateverEachSecond();
// Try it out.
+ 10
I tried but I was getting a certain error so I dnt know whether it was caused by it or not thus why I asked
0
Why not try it in some code?