0

I have an array with 4 items inside it. I want to loop though the array but during each loop i want to delay it for 5 seconds and do something such as an animation or playing sound:

The array is called donations:

for(counter = 1; counter < 4; counter++){

    setTimeout(
        console.log(donations[counter])
        //play_sound(child_node);
    , 1000);

}

The problem at the moment is instead of printing to the console every 1 second, it is doing all the prints at once. Isnt setTimeout supposed to introduce a delay.

deceze
  • 510,633
  • 85
  • 743
  • 889
Eclipse
  • 374
  • 2
  • 4
  • 17

0 Answers0