如何创建倒数计时器,其中用户以秒为单位输入时间并在javascript中从该数字显示为零?
var userChoice = parseInt(prompt("Type in time to countdown"));
var timer = setInterval(countDown, 1000);
// this is what i have
function countDown() {
console.log(counter);
counter--;
if (counter < 0) {
clearInterval(timer);
console.log("END");
}
}