Lesson 13: Not


#1


Hello everyone, I am having trouble with my code, please help me :slight_smile: Thanks guys.


https://www.codecademy.com/en/courses/javascript-beginner-en-qDwp0/2/4?curriculum_id=506324b3a7dffd00020bf661#


The error I get is: SyntaxError: Unexpected token else


// Declare your variables here!
var programming = false

var happy = function() {
  // Add your if/else statement here!
  if (programming === !true);
  {
    return true;
  }
  else
  {
    return true;   
  }


#2

Here:

You are already going to test if not true or otherwise in your loop condition.

This should suffice:

if (!programming)

Hope this helps! :slight_smile:


#3

I did that originally, but like I said the error I get is about the else section. Thanks though.


#4

You should just have one set of curly bracket that closes that whole function and its condition.

Like this:

var happy = function() {

if (!programming) 
    return true;
else
    return false;
};

Hope this helps! :slight_smile:


#5

That's what I dislike about coding, if I don't understand there isn't a way ofd understanding, I don't know why mine didn't but yours did, so I just copied that and pasted it... I feel so cheap, thanks though. I don't understand how the if statement doesn't need brackets like

var happy = function() {

if (!programming) {
return true;
}
else
{
return false;
}
};


#6

Please don't dislike coding!

The instruction says to:

write an if/else statement inside happy so that happy returns true if programming is false and false otherwise

That's why I believe it had to be so!


#7

I had the same problem !

You forgot the ; after your if statement:


#8

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