+ 3
Each button is missing the quotes for onclick attributes, onclick = "", Button with the Id="reset" does not have an onclick, In the function updateTimer() : there is a typo, seonds = 0 should be seconds = 0
19th Apr 2023, 8:59 PM
Chris Coder
Chris Coder - avatar
+ 3
Excuse me I'm having more trouble thinking of how to explain this, than finding the issues. Remove the parameters from the updateTimer function declaration and reference the global variables directly within the function. function updateTimer() { ... } } } time = `${hours}:${minutes}:${seconds}.${milliseconds}`; console.log(time) stopwatch.innerHTML = time; }
19th Apr 2023, 9:13 PM
Chris Coder
Chris Coder - avatar
+ 2
This isn't the complete solution. But I notice that your h2 class is "timerClock", but in JS its you're targeting an Id stopwatch= document.getElementById You can correct that with stopwatch = document.querySelector(".timerClock")
19th Apr 2023, 8:37 PM
Chris Coder
Chris Coder - avatar
+ 2
You have too many errors, so replace some of your code with this one and find the differences yourself: let milliseconds = 0 let seconds = 0 let minutes = 0 let hours = 0 //onload = ()=> stopwatch = document.getElementById("timerClock") // updates variables function updateTimer() { milliseconds++ if (milliseconds >= 100) { seconds++ milliseconds = 0 if (seconds >= 60) { minutes++ seconds = 0 if (minutes >= 60) { hours++ minutes = 0 } } } //stopwatch timerClock .innerHTML = `${hours}:${minutes}:${seconds}.${milliseconds}` } // starts the timer function start() { interval = setInterval(updateTimer, 10) } My stopwatch... 😎: https://code.sololearn.com/WR4UvCZ031Ml/?ref=app
19th Apr 2023, 9:42 PM
Solo
Solo - avatar
+ 2
If you have made the proper corrections, now, you should at least have a functional stop watch with working start and stop buttons. If you find anything helpful please like or if you find anything confusing, please ask more questions. - Happy Coding!
19th Apr 2023, 9:52 PM
Chris Coder
Chris Coder - avatar
+ 2
Callum Stewart You're welcome! No worries, many of us are here to learn, share knowledge, and experiences. And yes, simple typing mistakes can sometimes feel like the final boss.
20th Apr 2023, 12:57 AM
Chris Coder
Chris Coder - avatar