I have started learning JavaScript and I thought of trying a simple count down timer but I can't figure out.
function countdown() {
var count1 = 10;
while (count1 >= 0) {
setTimeout(function() {
document.getElementById("main").innerHTML = count1;
}, 1000);
count1--;
}
}
<p id="main" onload="countdown()"></p>
The page just stops/hangs. What is wrong with it?