Skip to content
Advertisement

Countdown displaying elements from an array. setInterval doesn’t cause a delay. The last element is displayed instantenously

I’m a beginner. I’d like to create a simple countdown from an array started by a button event listener. I want to display the elements of the array after a delay in p class=”countdownDisplay”. However, it doesn’t work the way I want. There’s no delay.

JavaScript
JavaScript

Advertisement

Answer

If you call the for loop, it will add from 0 until 5 at once and your code will not work. I hope the commented code below helps you:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement