When to 'While' and when to 'For'


Someone pls help me! I am stuck on an infinite loop and I don't know how to change my code!

var count = 12

while (count => 0) {
for (var i = 0; i < 50; i++) {


Because your condition i while loop is 12 > 0. Inside the loop you have count++, so now count = 13 (and it also > 0).
So you need to change your condition.

while - loops through a block of code while a specified condition is true


Thanks for the advice.
I solved it. :grinning:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.