am currently on the async setInterval task about creating a stopwatch and I don’t understand how to start the time, update the time, and how do I make use of that startTime variable or am I getting the hints wrong.
` const start = document.querySelector(".start");
const stopBtn = document.querySelector(".stop");
const reset = document.querySelector(".reset");
// disabled button before pressing start
reset.disabled = true;
stopBtn.disabled = true;
// according to instruction 3 and 4
let secInHour = 3600;
let secInMinute = secInHour / 60;
let secs = 60;
// i dont know how to update the time
function displayTime() {
let startTime = Date.now();
let millis = Date.now() - startTime;
// i think this is what hint 4 wants
let sec = 0;
let minute = 0;
let hour = 0;
let i = 0;
while (i < 10) {
document.querySelector(".clock").textContent = `${millis}${hour}:${millis}${minute}:${millis}${sec}`;
i++
}
if(sec == secs) {
minute += 1;
}
}
// once start is click it becomes unclickable while others become clickable
function startTime() {
start.disabled = true;
reset.disabled = false;
stopBtn.disabled = false;
}
function resetTime() {
stopBtn.disabled = true;
reset.disabled = true;
start.disabled = false;
document.querySelector(".clock").textContent = "00:00:00";
clearInterval(createClock);
}
function stopTime() {
start.disabled = true;
stopBtn.disabled = true;
reset.disabled = false;
clearInterval(createClock);
}
start.addEventListener("click", startTime);
stopBtn.addEventListener("click", stopTime);
reset.addEventListener("click", resetTime);
displayTime();
const createClock = setInterval(displayTime, 1000);`