Avatar of Allen Pitts
Allen Pitts
Flag for United States of America asked on

JavaScript If/else

Hello expert,
Working on a Javascript tutoriaa at Codeacademy.

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

Open in new window


The screen is saying there is a syntax
error at the line that has the 'else' keyword:
' Expected identifier and
instead saw 'else'. Missing semicolon.

But there is a semicolon after the console.log
statement. Any idea why it says it is looking for an identifier?

Thanks.

Allen in Dallas
JavaScript

Avatar of undefined
Last Comment
leakim971

8/22/2022 - Mon
SOLUTION
leakim971

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
Sar1973

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
leakim971

@Sar1973, You just add trouble with your comment
I don't see why you MUST reformat, change position of the bracket...
The following is valid:

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



    console.log("The answer makes sense!");



}



else
{




console.log("Error error error");




}

Open in new window

Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes