1

I have the following code and what I want is to show a message:

function startTimer(duration, display) {
    var timer = duration, minutes, seconds;
       setInterval(function () {
        minutes = parseInt(timer / 60, 10);
        seconds = parseInt(timer % 60, 10);
        minutes = minutes < 10 ? "0" + minutes : minutes;
        seconds = seconds < 10 ? "0" + seconds : seconds;
        display.textContent = minutes + ":" + seconds;
        if (--timer < 0) {
            timer = duration;
        }
    }, 1000);
}
window.onload = function () {
    var fiveSec = 5,   //seconds,
    display = document.querySelector('#UItimer');
    if (//logic here) {
        alert("time is over");
    }
    else {
        alert("timer started");
    }
    startTimer(fiveMinutes, display);
};

This display shows seconds on my app and i want When var fiveSec are over I want to display this message

Time is over

How can this be done?

  • you want to show this message for every fiveSec? – Atish Dipongkor - MVP Nov 23 '15 at 9:51
  • yes when 5 seconds are over i want to display that message – Nderon Hyseni Nov 23 '15 at 9:57