Toggle Button? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Toggle Button?

I need a way to create a toggle button for this counter. Google isn't helping and I have no clue where to start. https://code.sololearn.com/Ww3EOsdA4WdZ/?ref=app

11th Jun 2018, 9:33 AM
Daniel Cooper
Daniel Cooper - avatar
9 Answers
11th Jun 2018, 10:24 AM
Ben Allen (Njinx)
Ben Allen (Njinx) - avatar
+ 5
It is not like what you wanted Daniel Cooper. But I have made it to stop and start a loop function from some help from stackoverflow. Maybe it can help you. https://code.sololearn.com/Wx2K7j4sZnb8/?ref=app
11th Jun 2018, 9:48 AM
Akash Pal
Akash Pal - avatar
+ 4
https://code.sololearn.com/W4p2GKviuZ9p/?ref=app
11th Jun 2018, 10:51 AM
Calviղ
Calviղ - avatar
+ 2
Ben has provided the code, you wanted Daniel.
11th Jun 2018, 10:49 AM
Akash Pal
Akash Pal - avatar
+ 2
Akash Pal Thanks but I'd recommend using Calviղ s code. It's smaller.
11th Jun 2018, 10:54 AM
Ben Allen (Njinx)
Ben Allen (Njinx) - avatar
+ 1
It's good, but I was looking for a way to make a single button toggle the counter. And have it remember the number it stopped on. I'll have to do some digging. Thank you though Akash Pal
11th Jun 2018, 9:55 AM
Daniel Cooper
Daniel Cooper - avatar
+ 1
Also, thanks to everyone who helped me.
11th Jun 2018, 7:29 PM
Daniel Cooper
Daniel Cooper - avatar
+ 1
Daniel Cooper I updated with comments.
11th Jun 2018, 9:14 PM
Ben Allen (Njinx)
Ben Allen (Njinx) - avatar
0
Ben Allen (Njinx) Can you explain your code using comments? I want to be able to understand it. This is supposed to be a learning experience after all.
11th Jun 2018, 7:27 PM
Daniel Cooper
Daniel Cooper - avatar