题解 | #计时器#

计时器

https://www.nowcoder.com/practice/72c661d926494bd8a50608506915268c

function count(start, end) {
    console.log(start)
    var timer = setInterval(() => {
        if  (start < end) {
            start ++
            console.log(start)
        } else {
            clearInterval(timer)
        }
        
    }, 100)
    return {
        cancel: function() {
            clearInterval(timer)
        }
    }
}

全部评论

相关推荐

评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务