+4

Why Does The Time Show Before I Click The Button 🤔💔

https://code.sololearn.com/WmaNPtau0mtG/?ref=app

11/8/2019 4:09:13 AM

Siyabonga Samson Lukhele

6 Answers

New Answer

+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