Beginner JS project, got everything to work but I wanted to play around with colors. Looking to get the timer to change colors every 10 seconds. I thought a basic function would work but apparently not. I know I'm doing something wrong somewhere but I cant figure it out.
window.onload = function () {
let seconds = 00;
let tens = 00;
const roundTens = $("#tens");
const roundSeconds = $("#seconds");
const buttonStart = document.getElementById("button-start");
const buttonStop = document.getElementById("button-stop");
const buttonReset = document.getElementById("button-reset");
let Interval;
buttonStart.onclick = function () {
clearInterval(Interval);
Interval = setInterval(startTimer, 10);
};
buttonStop.onclick = function () {
clearInterval(Interval);
};
buttonReset.onclick = function () {
clearInterval(Interval);
tens = "00";
seconds = "00";
roundTens.text(tens);
roundSeconds.text(seconds);
};
function colorChange(color1, color2) {
if (color1.value === "00" && color2.value === "59") {
color1.style.color = "orange";
color2.style.color = "red";
} else if (color1.value === "00" && color2s.value === "00") {
color1.style.color = "green";
color2.style.color = "blue";
}
}
function startTimer() {
tens++;
if (tens <= 9) {
roundTens.text("0" + tens);
}
if (tens > 9) {
roundTens.text(tens);
}
if (tens > 99) {
console.log("seconds");
seconds++;
roundSeconds.text("0" + seconds);
tens = 0;
roundTens.text("0" + tens);
}
if (seconds > 9) {
roundSeconds.text(seconds);
}
}
colorChange();
};
startTimer should call colorChange (currently never called)