 # 19 help

(“Jon”.length * 2 / (2+1) === 2 )
if
{
}
else
{
console.log(“Error Error Error”);
}

why does this not work?

1 Like

these two lines

``````("Jon".length * 2 / (2+1) === 2 )
if

``````

should rather be

``````if("Jon".length * 2 / (2+1) === 2 )
``````

Remember this is the correct syntax for if/else

``````if(condition){
//statements
}
else{
//statements
}

``````
2 Likes

thanks for help didnt see the missing number after ===

1 Like

Hello Rydan,

Thank you very much for your help. I don’t understand one thing though if you might explain this it would be helpful. When I wrote my code I had problems with the first string I had written:
follow
if (“Jon”. length 2 / (2+1 ) === ). I don’t understand why in the code “2” follows after the “===” ???

i got this syntax error of ‘;’

if (“Jon”.length * 2 / (2+1) === 2 )
{
}
else
{
console.log(“This answer is true and makes sense!”);
}

This is what i wrote and I finally got it right! It was a little tricky for me at first! I hope this can help you in some way!

1 Like

@bobcat11 first things is there is an error in the code block. it should be

``````if (("Jon". length *2) / (2+1 ) === 2 )
``````

lets break it down

``````("Jon". length *2) / (2+1 )
``````

so the length of “Jon” will be 3 i.e

``````"Jon". length  -----> 3
``````

So now lets put that in the the expression above

``````(3*2)/(2+1)

//now we have
(6)/(3)   //==>2
``````

so now you know that the expression above will evaluate to 2
and that’s what the if block is checking
hence

``````if (("Jon". length *2) / (2+1 ) === 2 )
//will be the same as saying
if(2 === 2) // which is true

``````

Hope this helped?

3 Likes

thank you @jessica_davis17 for the hint 