I am trying to create a random timer from 10 to 60 seconds with half-second interval. But my code even though it looks to me that it should work does not work so I need someone else to tell me what is wrong.
function timer(t) {
    while (t >= 0) {
        setTimeout(function() {
            t--;
        }, 500);
    }
    alert("Time OUT!");
    console.log(t);
    return;
};
$("playbutton").click(function() {
    var randomTime = Math.round(Math.random() * 100 + 20);
    timer(randomTime);
    alert(randomTime);
});
 
     
    