Thunderstorm

 avatar
user_1671475754
javascript
3 years ago
353 B
1
Indexable
function thunderstorm(stormEvents) {
  if (stormEvents.length === 0) return;
  current = stormEvents.shift();

  if (current === "lightning") {
      console.log("FLASH!")
      setTimeout(console.log,400, 'BOOM!' );

  } else {
    //   log first
      console.log(current);
  }
  setTimeout(function() {thunderstorm(stormEvents)}, 200);
}