diff --git a/js-features/countdown/task.js b/js-features/countdown/task.js index e69de29bb2..a1acaafe71 100644 --- a/js-features/countdown/task.js +++ b/js-features/countdown/task.js @@ -0,0 +1,16 @@ +const startingSeconds = parseInt(document.getElementById("timer").innerText); + +function updateTimer() { + let currentSeconds = parseInt(document.getElementById("timer").innerText); + + if (currentSeconds > 0) { + currentSeconds--; + document.getElementById("timer").innerText = currentSeconds; + + setTimeout(updateTimer, 1000); + } else { + alert("Вы победили в конкурсе!"); + } +} + +updateTimer();