Expected ')' error, need help figuring out whats wrong


#1

var count = 0;

var loop = function(count){
while(count; count<3; count++){console.log("I'm looping!")

}

};

loop();

can anyone explain why i'm getting an expected ')' error ?


#2

You need a semi colon after:


#3

tried and it still says the same thing


#4

Okay I found out what level this is, so I now know what is supposed to happen.
SO LET'S DO THIS!:smiley:

The problems start here:

You are not supposed to put "count" in there, for there are no parameters for this one.

Your while loop also has a problem:

You already have learned this, but this is a FOR loop, not a while loop.

While loops are something like this:

 while(count < 3){
    console.log("I'm looping!");
    count++
 }

This while loop says that while count is lower than 3, it prints "I'm looping!". Count++ tells the count to go up by one in each loop it goes around. So this is what pretty much happens when you function this:

Code:

 while(count < 3){
        console.log("I'm looping!");
        count++
     }

What happens:

-----------------------------------------------------------------

First time:

count = 0
0 < 3
//SO
console.log("I'm looping!");

-----------------------------------------------------------------

Second time:

count = 1
1 < 3
//SO
console.log("I'm looping!");

-----------------------------------------------------------------

Third time:

  count = 2 
    2 < 3
    //SO
    console.log("I'm looping!");

-----------------------------------------------------------------

Fourth time:

count = 3
3 === 3
//SO

//*Loop ends*

Hope it helped!:smiley:


#5

it is intro to while loops, how did I use it like a for loop ?


#6

For loops are used like:


#7

thanks, I was wondering if that was for "for" or "while loops. the hint said to put count<3, and count++ so I got confused lol