Skip to content
need help with countdown function
Profile icon
thakurjngshh8

Write your function 'countdown' here
// For example with the argument '3', it should log:
// countdown(3)
/*
3
2
1
Blast off!
*/

You are viewing a single comment. View All
Profile icon
tussiez
  1. This looks like a school assignment XD
  2. Anyways:
let countdown = 3; let loop = setInterval(function() { if(countdown > 0){ countdown -= 1; console.log(countdown)://Log the countdown } else { clearInterval(loop);//Stop looping console.log('Blast off!'); } },1000);//Repeat every second