Syntax Robot seems to think I'm wrong...I probably am


#1

("Jon".length * (2 / 3) === ("Jon".length) * (2 / 3))
{
console.log("The answer makes sense!");
}

else

{
console.log("Error Error Error");
}


#2

Hi there,

You've used the keyword else (part of an if else statement) without first starting off with an "if".

Add an "if" at the start of your code it will run and console.log correctly.

Thought it might be worth clarifying the above, the structure your code should take will be as follows:

if (a === b ){
    //Do something
}
else{
   //Do something else
}

Hope that helps!


#3

Even with 'if' in there, I am having same problem!! The syntax is being flagged as:

Oops, try again.
There was a problem with your syntax.

and I can not see what is wrong >_<

if ("Jon".length * 2 / (2+1) === )
{
console.log("The answer makes sense!");
} else
{
console.log("Error Error Error");
}

I know that the '=== )' is incorrect but the task hint says:

"Make sure not to delete any of the provided code. It could cause your code to fail!"


#4

When you use a comparison operator, there has to be something on each side of it. From the error message, it seems that if you were to reset the code and try from scratch again, you might be able to get it to pass.

Something I do to debug sometimes is paste the code into jsfiddle. Then you can run the code there, and see what kind of error you get in the console (Ctrl + Shift + C in Chrome to open the console). Searching the error in Google will help find a solution.


#5

Yeah, I tried re-writing, reloading etc and typing it in codepen and it was still buggy, I know the comparison bit was wrong and worked as '2 / 3)' than '(2 / (2+1) ===)'
butttttttt... the part that threw me off was the Hint saying not to touch any of the written code,

I literally did it after I posted this !!
Thankyou for your help anyway ^^