When to 'while' and when to 'for'


#1



https://www.codecademy.com/courses/javascript-beginner-en-ASGIv/2/1?curriculum_id=506324b3a7dffd00020bf661#

SyntaxError: Unexpected identifier I really cant find the problem here


var myCondition = true;

function name(){
    while(myCondition)
    console.log("Single loop.")
    myCondition = false
}


var i = 0; 

for(var i = 1; i < 3 i++){
        console.log("Same thing three times")
}


#2

\

You're missing a semi-colon.

for(var i = 1; i < 3; i++) {

Hope this helps! :slight_smile:


#3

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