Menu
I am trying to build a counter that counts to 10 and then when it hits 10 goes back to 0 but it counts every 500ms.
Like 0 /500ms/ 1 /500ms/ 2 /500ms/ 3 etc.
I have some problems with the counter. Here is the code.
“`
let counter = 0;
function countIt() {
if(counter <= 10) {
setInterval(() => {
counter++
}, 500)
} else {
counter = 0;
}
}
countIt();
console.log(counter)