Thunderstorm

 avatar
user_1671475754
javascript
2 years ago
353 B
1
Indexable
Never
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);
}