16. It looks like your if/else statement didn't log "The condition is false"


#1

if(console.log(4*4===17))
{
console.log("The condition is true");
}
else
{
console.log("The condition is false");
}

Is my code above, and even in the terminal it prints false and the "The condition is false." but I'm still getting the error
Oops, try again. It looks like your if/else statement didn't log "The condition is false" to the console.


Lesson 16 - please help - error message
#2

The problem is here; your trying to log those numbers to the console instead of just saying if number is equal to number then print this statement.

All in all don't say console.log, otherwise I can't find anything else.

One other thing: make sure everything is spelled correctly and has all punctuation in it's proper places. Whenever exercises want me to print something out exactly then I just copy and paste what they want me to print out so that I don't misspell anything :slight_smile:

Hope this helped :slight_smile:


#3

Hey William
I actually added the first console.log to the if statement to at least see if the internal calculator was returning a false statement, which it did. Prior I didn't have that statement. It was:
if(4*4===17)
{
etc.
But the above statement SHOULD have returned a false in its own right, and thus why I added that console.log statement just to see.

Either way, it is returning a false, but not working.


#4

Could I see a screenshot of your code and the error message? Also, make sure that you weren't suppose to add periods or any other sort of punctuation into your console.log statements.


#5

Depending on what you were planning, your test might not be doing quite what you had in mind.

console.log always returns undefined. Your example above will log true or false first, but then, no matter what equation you put in there, it will print "The condition is false".

if( 4*4===17 ) // if(false)
if( console.log( 4*4===17 ) ) // if(undefined)
if( console.log( 4*4===16 ) ) // if(undefined)

#6

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