+ 4
Why Does The Time Show Before I Click The Button đ€đ
6 Answers
+ 10
That what the code was supposed to dođ
If you need to update with real time, edit the <button>
<button onclick="setInterval(printTime, 1000);">Show current time</button>
+ 6
Remove that
setInterval(printTime, 1000);
in JS
As setInterval is calling the 'printTime' function....
+ 3
Okay, here is the logic.
Create a flag/Boolean variable. Set it to false initially.
In if condition check if that variable is true or not, if it is false don't run the setInterval. But when you click the button first time set variable to true and then when it will check for condition it will be true so interval will run and that's how you can make a clock working.
Try it đ€
+ 1
Come On It's Just Too Boring That Way Cause It Just Stops There đ€đ
+ 1
Ohh...I Was About To Ask That Question,Thanks For The Tipđłâ€ïž
0
Ohđ€