javascript - make something happen every 1 second? -
i challenging myself creating pomodoro timer. i'm having trouble making timer count down automatically... far thinking of using loop although not count down 59..58..57.. on screen. question can make slower...
i have if/else statement allow go 59 - 0 reset 59 again.
if (s >=0 && s < 10 ) { $("#second").html("0"+s); s-- } else if ( s <= 0) { s = 59; } else { $("#second").html(s); s-- }
function runtimer() { let count = 59 setinterval(() => { console.log(count) count-- if (count < 1) count = 59 }, 1000) } runtimer()
Comments
Post a Comment