right now I have created a digital clock function. Now for my next task is to change the id colour once it has hit the target number - 10. Because I am new to this and new to functions and trying everything I can to make myself understand how it works, I am struggling really bad here. Why does the popUp function not work?
var realTime = new Date();
var seconds = realTime.getSeconds();
var minutes = realTime.getMinutes();
var hours = realTime.getHours();
function currentTime() {
var realTime = new Date();
var seconds = realTime.getSeconds();
var minutes = realTime.getMinutes();
var hours = realTime.getHours();
if (seconds < 10) {
seconds = "0" + seconds;
}
if (minutes < 10) {
minutes = "0" + minutes;
}
var digitalClock = hours + ":" + minutes + ":" + seconds;
if (hours > 11) {
digitalClock += "PM"
} else {
digitalClock += "AM"
}
document.getElementById("time").innerHTML = digitalClock;
}
setInterval(currentTime,1000);
function popUp() {
var bodyColour = document.getElementById("time");
var changeColour = document.getElementById("time").backgroundColor = "lightblue";
document.getElementById("time").style.backgroundColor = changeColour;
document.getElementById("time").style.backgroundColor = bodyColour;
if (seconds = 10) {
bodyColour = changeColour;
}
}