📜  设置计时器 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:26.095000             🧑  作者: Mango

代码示例1
const prompt = require('prompt-sync')();
//You gotta download prompt-sync by doing npm i prompt-sync
var time = prompt("Give time in seconds: ")
time = parseInt(time)
setInterval(function(){
    console.log(time)
    if(time = 0){
        console.log("Time over")
    }
    else{
    time = time - 1}
}, 1000);