Ask coding questions

← Back to all posts
CookieClicker
EmmaGao8

I have a value var x = "2". How can I increment x each second so that one second from when I defined x, x will equal to 3?

Answered by GameDev46 [earned 5 cycles]
View Answer
Voters
EmmaGao8
Comments
hotnewtop
GameDev46

You can use javascripts setInterval method!

Simply use the line of code:

Where someFunction is your function to change the cookies by 1 and the number is how many milliseconds do you want to wait before calling it again. So the someFunction function will be called every second!