+ 1

How can I stop a function and start another From the other?

I have a function than print A every second then i want than that function stop it and start another that print B. Do you can understant me? https://code.sololearn.com/WYypuFNoL01M/?ref=app

13th Aug 2019, 5:27 AM
Propy Grammar Moruzian
Propy Grammar Moruzian - avatar
8 Answers
+ 6
Hint: try to print func_A.t1 before apply clearInterval on it and see what its...
13th Aug 2019, 5:52 AM
KrOW
KrOW - avatar
+ 3
Propy Grammar Moruzian I know what you want do but mine was an hint for make you think about the problem of your code... Run this https://code.sololearn.com/WAL6sCsI6j96/?ref=app and see what is printed on console when the callbacks are called...
14th Aug 2019, 6:05 AM
KrOW
KrOW - avatar
+ 2
Just now i seen 👍
15th Aug 2019, 5:29 AM
KrOW
KrOW - avatar
+ 1
Yes, but what I try to do is stop the print function by using the method (function b)
13th Aug 2019, 6:03 AM
Propy Grammar Moruzian
Propy Grammar Moruzian - avatar
+ 1
Thanks for your answer :)
13th Aug 2019, 6:04 AM
Propy Grammar Moruzian
Propy Grammar Moruzian - avatar
+ 1
What I want is that when "B" starts printing, "A" stops printing
14th Aug 2019, 6:40 PM
Propy Grammar Moruzian
Propy Grammar Moruzian - avatar
+ 1
Propy Grammar Moruzian setInterval return the id (an integer) for stop the inteval right? If it return good but when you try to "access" to it outside its undefined (have you runned my code?) , it mean than you access to it in bad way then you really dont stop the interval...
15th Aug 2019, 5:26 AM
KrOW
KrOW - avatar
+ 1
I could solve it, thank you very much for everything, good luck
15th Aug 2019, 5:28 AM
Propy Grammar Moruzian
Propy Grammar Moruzian - avatar