Lesson 12/13 having challenges


#1

What could probably be wrong with this code:

var sleepCheck =function(numHours);

if (numHours>=8);
return "You're getting plenty of sleep! Maybe even too much!";}
else
return "Get some more shut eye!";
console.log(sleepCheck(10));


#2

Where is your opening curly bracket? ... {
You also closed the code too early, remember the code that goes inside the { curly brackets } is the if/else statement
and to call sleepCheck, you do not need to console.log it, just a simple sleepCheck(10); will do
try to clean it up using the above suggestions
G Luck


#3

the FUNCTION talk

var myFunc = function( param1, param2) {
       //Begin of  anonymous FUNCTION-BODY
       //VARIABLE -myFunc- has an -anonymous function- assigned
       //this -anonymous function- has 2 PARAMETERS param1 and param2
       //param1 and param2 PARAMETERS are used 
       //as -local- VARIABLES throughout the FUNCTION-BODY

      console.log( param1 + " and " + param2 ) ;

      //End of anonymous FUNCTION-BODY
};

If you want to call/execute the anonymous function
you will have to add a pair of parentheses to the variable myFunc
like
myFunc();
As the anonymous function was defined
as having 2 parameters
you have to provide 2 arguments
in our case 2 string VALUES "Alena" and "Lauren"
like
myFunc("Alena","Lauren");

some quotes from the outer-world:

**argument is the value/variable/reference being passed in,
parameter is the receiving variable used within the function/block**

OR

**"parameters" are called "formal parameters",
while "arguments" are called "actual parameters".**


#4

@willy2k2nggmail_com
Read the function-talk
and
http://javascript.crockford.com/code.html for the structure of the if-statement.


#5

I have debugged it with your help.Thanks


#6

Thanks a bunch, the explanation went a long way.