Stuck on getting started with programming no.28


#1

https://www.codecademy.com/courses/getting-started-v2/4/5?curriculum_id=506324b3a7dffd00020bf661#

after inputting this code (below) and trying to run it, I get a syntax error telling me that 'expected '('', but I cannot figure it out. can somebody please help? :slight_smile: thanks in advance!

var myname = 'adam';
if
{   myname.length === 4;
console.log('I finished my first course!');
}
else
{   console.log('no you did not');
}

#2

You are using brackets for your condition of you if statement. You're supposed to use parinthesees. It's looking for (, but you used {.

if(1 == 1){
  console.log("This is True.");
}else{
  console.log("This is False.");
}

#3

sorry if I sound stupid, but what do you mean?


#4

The condition of your if statement needs ( ) not { }. For a statement ( ) holds what you're checking, and { } hold what the statement will do.

if( /*this is the condition checking to see if the statement will run*/ ){
  /*this is the block that will be run if the condition is true*/
}

#5

look at your if statement:

if
{   myname.length === 4;
console.log('I finished my first course!');
}

and then how it should be:

if(1 == 1){
  console.log("This is True.");
}

do they look the same to you? the condition (myname.length === 4) should be before the opening curly bracket ({) and in parentheses (()).

Remove the semi-colon from the condition, it doesn't belong there

If you need more help, post an updated version of your code


#6

thank you very much! =)


#7

Thank you soooo much!


#8

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