Time delay within a loop?

You need to put the code in a function, and then call it whenever you want to start the count again. However, you should keep in mind that the setInterval() function runs in the background until it finishes its count. Once it’s finished, you can call it again.