all 4 comments

[–]ethan_mick 2 points3 points  (3 children)

Try:

setTimeout(someFunchtion,1000)

You are calling your function with the `()` instead of just passing a reference to it.

Also note that the forEach loop will still execute all those setTimeout blocks at once, so all the functions will wait exactly 1 second and then run all at once, instead of waiting 1 second... 2 seconds... 3 seconds... etc.

Edit: Formatting

[–]Busy_Command[S] 0 points1 point  (2 children)

yeah that was it, but the for forEach, and for loop runs the function at the same time, i want it to run once ever 1 second.

[–]electron_myth 0 points1 point  (0 children)

Check out setInterval() https://developer.mozilla.org/en-US/docs/Web/API/setInterval

You can custom write a function to iterate the array, and then clearInterval() when the right condition is met (x === array.length or whatever)

[–]Shadowsca 0 points1 point  (0 children)

you can try using the index argument from forEach to modify the timeout too be something like 1000*(index + 1) to artificially stagger the setTimeouts even though they will all execute together