13. Not


#1

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

Hi,

I wonder what is wrong with this. It says that: "Oops, try again. There was a problem with your syntax. And:"SyntaxError: expected expression, got keyword 'else'." Should not there be 'else'?

// Declare your variables here!
var programming = false;

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

#2

HI here

if (programming = !true)

you should change the = with ===


#3

Now it says that:"Oops, try again. There was a problem with your syntax." And: "SyntaxError: expected expression, got keyword 'else'".

// Declare your variables here!
var programming = false;

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

#4

here remove the ; after the closing }

if (programming === !true) {return true}; <== this one

#5

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

Why? The ! reverses the statement. You say if (programming) instead of if (programming === true), and you can say the opposite if(!programming) instead of if (programming === !true) ... you can also say if (!programming === true) but one way is less writing. What the "!" is doing is making the statement opposite (negating) the condition.


#6

I'm just replying because honestly these forums are so helpful. Every time I have a question, someone has already asked and answered it.

In this situation, my issue was I had if (programming !true), I forgot my === sign, d'oh!