Variables & setInterval - JAVASCRIPT | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Variables & setInterval - JAVASCRIPT

I have a random number that is picked every 2.36 seconds, and I have to use it in a function whose setInterval is of 0.005 seconds (so the 2 functions have different timing). The first variable is in its own function, but I have to use it in the other function. The thing is that, because they have different setInterval methods, I can’t put them in the same function, then how can I access the first variable from the second function?

17th Feb 2018, 1:10 PM
Andrea Blancuzzi
Andrea Blancuzzi - avatar
1 Answer
0
Hi Andrea, it would be better if you provide a code.
17th Feb 2018, 1:52 PM
Jonathan Pizarra (JS Challenger)
Jonathan Pizarra (JS Challenger) - avatar