Does anyone help me solve this problem? when I click on 0, it gets -2 and every click the chronometer accelerates! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Does anyone help me solve this problem? when I click on 0, it gets -2 and every click the chronometer accelerates!

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

14th Aug 2018, 7:30 PM
Neymar Silva
Neymar Silva - avatar
20 Answers
+ 6
I've figure out the remove of the event handler. This makes it so you can put the number back to 10 and only have the two handlers decrementing the count preventing the same kind of timer issue you had. https://code.sololearn.com/WcvgDcFjEEtN
15th Aug 2018, 12:08 AM
John Wells
John Wells - avatar
+ 9
Basically, you prevent going below zero. The timer sped up because you kept adding a new decrement timer.
14th Aug 2018, 11:38 PM
John Wells
John Wells - avatar
+ 7
Not the best method as the event handler should be cancelled, but this does prevent your issues. https://code.sololearn.com/WOtnF9nug9Yv
14th Aug 2018, 11:29 PM
John Wells
John Wells - avatar
+ 7
It was a win-win. I learned how to remove event handlers that I've never done before so thank you, too. I normally put my handlers in my HTML so, while I knew how to add them in JS, I had no clue about removing.
15th Aug 2018, 12:17 AM
John Wells
John Wells - avatar
+ 7
Sure, but not within SoloLearn playground. Each run here is a reset server environment so no way to maintain the data.
15th Aug 2018, 2:48 AM
John Wells
John Wells - avatar
+ 6
I've never done that as web development is not my goal. But, you should be able to write cookies with data to reload each time the page gets loaded.
15th Aug 2018, 2:52 AM
John Wells
John Wells - avatar
15th Aug 2018, 3:03 AM
John Wells
John Wells - avatar
+ 2
I don't understand what you are trying to do
14th Aug 2018, 7:39 PM
J.G.
J.G. - avatar
+ 2
😱yeeess i love you brother ❤❤❤
14th Aug 2018, 11:36 PM
Neymar Silva
Neymar Silva - avatar
+ 2
thank you!!😁🤙👏👏👏
14th Aug 2018, 11:38 PM
Neymar Silva
Neymar Silva - avatar
+ 2
Yes, I understand, thanks for the help!
14th Aug 2018, 11:49 PM
Neymar Silva
Neymar Silva - avatar
+ 2
yees 👏👏👏
15th Aug 2018, 12:11 AM
Neymar Silva
Neymar Silva - avatar
+ 2
Thank you very much for the minute you had to help me thank you very much!
15th Aug 2018, 12:13 AM
Neymar Silva
Neymar Silva - avatar
+ 2
❤❤❤ we won
15th Aug 2018, 12:20 AM
Neymar Silva
Neymar Silva - avatar
+ 1
one last doubt Can I create a button to save the points?
15th Aug 2018, 2:31 AM
Neymar Silva
Neymar Silva - avatar
+ 1
because I generated a mobile apk, what happens when I click on the diamond and I exit the app it does not save at the point that it stopped it comes back all over again! when I come in again.
15th Aug 2018, 2:35 AM
Neymar Silva
Neymar Silva - avatar
+ 1
I understand, but will there be a way to make the points continue where they stopped when I close the app and reopen?
15th Aug 2018, 2:50 AM
Neymar Silva
Neymar Silva - avatar
+ 1
ok😁🤙
15th Aug 2018, 2:54 AM
Neymar Silva
Neymar Silva - avatar
0
click on the diamond until it reaches 0 then you click again and there it will appear -2 then you will click again -4 and the timer will be getting faster I want to take it off!
14th Aug 2018, 7:42 PM
Neymar Silva
Neymar Silva - avatar
0
The more you click the timer, the faster you risk restarting faster!
14th Aug 2018, 7:43 PM
Neymar Silva
Neymar Silva - avatar