Why is it not a function ? help!


#1

Hello!!
i'm learning how to use Non(!)
I CANNOT understand why 'heureux' is not a function ???!!!!! please help me thanks !!!!!

var programmation = false;

var heureux = function(programmation){
if(!programmation)
{return heureux =true}
else{return heureux =false};
};


#3
  1. remove 'programmation' from the function parameters. Your function doesn't need parameters and you declared your variable globally -- outside of the function.

  2. put a semi-colon ( ; ) at the end of your statements (ex: return true;).

  3. why are you returning your function true/false? ( return functionName = true; ). That's improper. If you're returning true, just return true or false--don't overthink it. You're also not assigning true/false to return. Your syntax is improper all-around. It's just return true/false; (ex: return true; / return false; )

  4. you don't need a semi-colon on the closing bracket of the else statement ( }; ). It only needs to be tied to the closing bracket of the function.

Proper Code:

var programmation = false;

var heureux = function()
{
	if(!programmation)
	{
		return true;
	} 
	else
	{
		return false;
	}
};

heureux();