with this following code
function clock(){
/*var message = document.getElementById("timer");
message.innerHTML = "The time is " + Date();
*/
var msec = 00;
var sec = 00;
var min = 00;
msec += 1;
console.log(min + ":" + sec + ":" + msec);
if (msec == 60) {
sec += 1;
msec = 00;
console.log(min + ":" + sec + ":" + msec);
if (sec == 60) {
sec = 00;
min += 1;
console.log(min + ":" + sec + ":" + msec);
if (sec % 2 == 0) {
alert("Pair");
}
}
}
document.getElementById("timer").innerHTML = min + ":" + sec + ":" + msec;
}
What I wanted to do is a simple timer that starts on a window load, and every milisec it increments the up to 60, which by then resets to 0 and adds 1 to the seconds which when seconds reaches 60, goes to 0 and increments minutes by 1. Sorta like a stopwatch.
It seems I'm not incrementing properly but I don't know how to increment it.
I'm calling the function with a setInterval which I don't know if its right:
var timer = setInterval(clock(), 1000);
msecin the if statement should be 1000, not 60.