+ 2

SoloLearn stops working and so does my phone when using loops.

SoloLearn stops working when I use the for, while and do while loops. The code doesn't work unless I restart the app. Does this happen to anyone else?

7th Jan 2021, 8:42 PM
Lisa :)
Lisa :) - avatar
8 ответов
+ 2
Is that all the code? That code shouldn't be causing an issue as long as there isn't another variable i that could be getting changed in the loop and then attempting to use it after in the wrong context. To avoid that issue all together you should use the 'let' keyword to make the i variable local. for(let i=1; ...etc You may want to close the app or browser etc and restart your device or computer and try again.
7th Jan 2021, 9:41 PM
ChaoticDawg
ChaoticDawg - avatar
+ 4
Maybe you have an infinite loop without an exit condition
7th Jan 2021, 9:16 PM
Sonic
Sonic - avatar
+ 3
Try a for loop that iterates a finite number of times and it should work.
7th Jan 2021, 9:17 PM
Sonic
Sonic - avatar
+ 1
Yeah mabye I just started JavaScript, how would I know😂?
7th Jan 2021, 9:17 PM
Lisa :)
Lisa :) - avatar
+ 1
Post your code
7th Jan 2021, 9:19 PM
ChaoticDawg
ChaoticDawg - avatar
0
Well if i tried a piece of code ran it ,changed it ran it again ,changed it back to what it was first and ran it, itwouldn't work. After a while my key board won't respond all the buttons will either not respond or are delayed by several seconds.
7th Jan 2021, 9:20 PM
Lisa :)
Lisa :) - avatar
0
This is an example for (i=1; i<=5; i++) { document.write(i + "<br />"); } Then I would change it to for (i=1; i<=6; i++) { document.write(i + "<br />"); } Then back to for (i=1; i<=5; i++) { document.write(i + "<br />"); }
7th Jan 2021, 9:31 PM
Lisa :)
Lisa :) - avatar
0
Thanks you, will do
8th Jan 2021, 9:55 AM
Lisa :)
Lisa :) - avatar