I tried to create a really simple Javascript clock that would countdown to 0 from a time that the user specifies, but for some reason it keeps returning 'undefined' as a string. Here is the source of the clock:
function startTimer(duration) {
desap = duration - (new Date).getTime() / 1000;
var timer = desap,
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 = "Ends in " + minutes + " mins and " + seconds + " secs";
if (--timer < 0) {
display = "Ended";
}
return display;
}, 1000);
}
document.write(startTimer(999999999999999))