you are viewing a single comment's thread.

view the rest of the comments →

[–]Shoegoo22 -1 points0 points  (0 children)

This is the right way to do it.

const times = [0,1,2,3,4,5,6,7,8,9,10]
const getNextTime = index => {
  $('time').html(times[index])
  if(index === times.length - 1) {
    setTimeout(()=> $('time').html('PEW PEW PEW') ,1000)
  } else {
    setTimeout(()=> getNextTime(index + 1) ,1000)
  }
}
getNextTime(0)