8/11 Syntax Error


#1

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

I'm currently having issues with the exercise above, where, when I entered the code below, the console returned the message, "SyntaxError: Unexpected token )" I know the issue is somewhere within my for loop, as I ran the while loop on its own, it worked just fine, but the for loop still printed the Syntax Error, when I ran it on its own.


var derp = true

var herp = 1

while(derp){
    console.log("This is a while loop, executed once.");
    derp = false;
}

for(herp < 2; herp++){
    console.log("This is a for loop, executed once.");
}


#2

Next thing to do then is looking up syntax for a for-loop

google: mdn for loop


#3

cant you just tell him what part he is missing? like I know you are trying to have him find the answer on his own but couldn't you just explain the part he is missing? I was going to but I didn't want to ruin what you told him to do. I know that we aren't supposed to just give other people the code that would fix their program, and I avoid doing that(although sometimes its really hard because the person doesn't get it) but wouldn't explaining the syntax of a for loop be ok? I want to know so I don't mess up later when trying to help people.


#4

There are so many possible problems that having the answer to one of them is next to useless

Better to figure out how to solve all similar problems

The problem here as I see it isn't the for-loop, but in not finding that information


#5

ok, I was just curious. and I didn't want to go in and ruin what you had going so that's why I didn't just tell him what I saw.


#6

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