0

How do you call a function every second in JavaScript?

I know that it’s something to do with setInterval but I can’t figure it out. Here’s what I have so far: function plusOne { document.getElementById("main").innerHTML = x; x++ } let x = 0 setInterval(plusOne,1000)

28th Jul 2019, 7:28 AM
Jack Woods
Jack Woods - avatar
1 ответ
+ 1
It's all correct, except you forgot the parenthesis in the function declaration. You just need to use function plusOne () { to make it work
28th Jul 2019, 7:40 AM
Aaron Eberhardt
Aaron Eberhardt - avatar