#19 JS has bad attitude!


#1

if
(2 + 2 === 4 )
{ console.log("true")
}
else {
console.log ("Error Error Error")
}

This was my code, JS says that the if/else statement has to evaluate to true when it does evaluate to true.


#2

You're right. Your code is correct. This is most likely a bug in Codecademy. Try refreshing your page or using another browser for this exercise.


#3

Actually, the lesson states

  1. "Complete the missing bits of code" to construct the if / else statement. Make the condition evaluate to true.
  2. Finish the else statement by printing out the string "Error Error Error" to the console.

And then it gives you this statement:

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

It's asking you to fill in what's missing, and when it's done it will evaluate as "true".

So you shouldn't be taking away anything from what's already there, instead you just need to add things. Try resetting your code and trying again with this in mind. The console is looking for the entire "if" parameter to evaluate to true, and then for you to fix the else statement completely.

I hope this helps!


#4

Yes, but I already got the code back to default ( I'm sorry if this sounds weird I'm from different country) and it still doesn't work:

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

what's the problem?


#5

Also I pressed reset and did the whole thing again. Here's my code:

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

{ console.log("The answer makes sense!");
}
else {
console.log("Error Error Error")
}

It worked.