function updateCounter(){
    console.log(delay);
    delay = delay - 1000;
    $('#counter-value').html(delay / 1000);
    if(delay <= 0){
        clearInterval(loopID);
    }
}
var delay = 5000;
var loopID = setInterval(updateCounter(), 1000);
I don't understand why it doesn't work, could someone help me? I've looked many things but couldn't end up making it. :(
 
    