Q 12 Can anyone see where the syntax error is?


#1


#2

@tommyturndown,

For the Javascript Interpreter a semi-colon-; is an End-of-Statement indicator.

You will have to remove the semi-colon-;

  • right after the parameter-holders of your function-definition
  • in your IF ELSE statement.

At the =end= of your function-definition you will have to use an EXTRA closing-curly-bracket-}
with which you close the FUNCTION-BODY.


#3

Did what you said to do, only still having problems with the IF line. 33 posts on this section alone. Thanks for your help anyway.


#4


#5

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".**


#6

Hi,
Sorry, I do not speak English very well, It is a syntax error in the If/Else these should not end in ; therefore it should be this way:

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

Please let me know how it went

Good look


#7

@chipsolver15394, @tommyturndown,

And he should also use an opening-curly-bracket-{
to begin his FUNCTION-BODY


#8

Hello,
leonhard.wettengmx.n

Thanks for the explanation. It is great. It worked for me. :slightly_smiling: