I'm trying to code my own timer from scratch. Complete noob here. I know there's a good amount of tutorials out there about building a timer, but from experience, whenever I use examples I don't really learn. Here's the code I come up with:
<p id="myTimer">Blank Text</p>
var timer = 60;
function updatePLEASE() {
timer--;
}
while (timer > 0){
console.log(timer);
document.getElementById("myTimer").innerHTML = timer;
setTimeout(updatePLEASE(), 1000); /* replicate wait 1 second */
}
When it runs, it shows "1". I thought it was returning a boolean value at first until I added the console.log and saw that the script does thankfully countdown from 60 down to 1. But, the script seems to only use setTimeout once.
Why doesn't the script wait 1000 ms before running the loop again? Or better question: Am I using the setTimeout function correctly?