let spans = document.querySelector(`#spans`);
let hrs = document.querySelector(`#hrs`);
let mins = document.querySelector(`#mins`);
let secs = document.querySelector(`#secs`);
let start = document.querySelector(`#start`);
let stop = document.querySelector(`#stop`);
spans.style.fontSize = "10em";
let preFix = 0;
let num = 1;
let secspreNum= 0;
let minspreNum = 0;
let hrspreNum = 0;
let myFunc = ()=> {
setInterval(()=>{
switch (num){
case num===1:
mins.innerHTML = `0` + num;
num ===0;
secs.innerHTML =`0`+ num++;
default:
console.log(`default test`)
}
} , 1000);
};
start.addEventListener(`click`,myFunc)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8>
<meta http-equiv="X-UA-Compatible" content="IE-edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="spans">
<span id="hrs">00</span>:<span id="mins">00</span>:<span id="secs">00</span><br></div>
<button id="start">Start</button>
<button id="stop">Stop</button>
<script src="go2.js"></script>
</body>
</html>
Hello all, I'm currently working on building a stopwatch but I've encountered an issue during the process. I am attempting to incorporate a switch statement that will update the minutes when the seconds reach 10, however, I am facing some unexpected behavior where the default statement is being executed instead of the specified case. I initially set the 'num' variable to 1 and expected it to match 'num===1', but it seems this isn't happening as planned. Can someone please provide insights or suggestions? Thank you!