.13.Not


#1

Ek gaan volgens die instruksies !

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

There was a problem with your syntax.

// 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 this line

if (programming!true;)

first you should remove the ; after true you should add the === between programming and !true


#3

it doesnt work it still gives the same message


#4

why then do they give me the "Not" operator to use and I don't even have to use it.

!true; // => false
!false; // => true


#5

so it's like that

if (programming === !true)

if so can you post your new code?


#6

it still passes without the " ! ".


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


#7

it pass because the function should return true in your case the the condition of the if statement is false so it run the else statement which return true and let your pass the lesson.


#8

It's the line if
(programming!true;){
which is wrong.
Try using this instead:
if (!programming) {


#9

That's the answer.

var programming = false;


var happy = function() {
    if (!programming === true) {
        return !programming;  
    } else {
        return !programming;
    }
};

This task is stupid 'cause you can just write

var programming = false;

function happy(p) { 
return !p; 
};
happy(programming);

#10

I have trouble with this too :frowning:
Here's my code

var programming = false;
happy(programming);

var happy = function(programming) {
  if(programming == !true)
  {
      return true;
  }
  else
  {
      return false;
  }
}

Error msg:

Oops, try again.
It looks like your happy function returns false instead of true when programming is false

Here a screenc: http://i.imgur.com/UmOizxZ.jpg


#11

Hey, here is your problems. It should look like this:

/*2nd line of code*/
var happy = function() {

/*3rd line of code*/
if (!programming === true) {


#12

Hmmm...
Still not working

Weird, I tried it the same way in C# (Visual Studio 2015) and compiled & executed, and I had no trouble at all.


#13

Hi your if statement is like that

if (!programming === true) {{
   return true;
}

Do you see it now ?

Hint

if (!programming === true) {{ <--- #you have two open {
   return true;
}


#14

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