Lesson 3-for or while


#1


Lesson 3-for or while


showing a syntax error.Anyone can help me please.


var count=true;
while(count<5)
{console.log("I Love Coding");
count=false;
    }


#2

Please, is this all your code? What syntax error are you getting, please? There should be a 'for' loop.

That said, this set of code will cause a browser crash. Your while statement should be 'true' which you've set as

var count = true

See below.

var condition = true;
while(condition) {
    // Says "Hello!"
    console.log("Hello!");
    // Avoid infinite loops
    condition = false;
}

#3

Thank You so much.It worked.:slight_smile:


#5

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