The first ) is an unexpected token and i don't know why


#1



I can't seem to find what's wrong with the code, it thinks the ) at the end of the condition for the while loop is incorrect. I have redone the code 2 times and it still doesn't work. If you look in the hint box, it even shows that i need to write my code that way.


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


SyntaxError: Unexpected token )


var chicken = true;

while(chicken){
    console.log(chicken);
    chicken = false
}

for(i = 5, i < 7, i++){
    console.log(i)
}


#2

This should check when chicken = false

So:

(chicken == false)


^The above two missing semi colons


#3

It didn't work, it's still not going through due to the ) at the beginning. I've been stuck on this for hours and nothing seems to make it work.


#4

Refresh your page and do as I said above I'm sure it will work


#5

I did refresh the page, it still doesn't work. It doesn't matter what I change to the while loop. I've experimented with it for a little bit longer and apparently the for loop is causing the problem with the while loop.

When i remove the for loop, the while loop has no issue with the ) and { at the end of the condition. I don't know how or why the for loop is causing the while loop to not work.

EDIT: I put the for loop in front of the while loop and now the for loop's ) and { won't work. If i put 2 for loops in there, the first one won't work still. But with 2 while loops, everything works fine and both of them will log onto the console. With 1 for loop, it won't work. Basically the for loop is the problem.


#6

@ajaxsolver51426

Have a close look at

for(i = 5, i < 7, i++){

Have a read
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for


#7

Thank you, that worked.