You did not give function name, pass it a name!


#1

So I believe I have debugged this:

greeting var func{name}(console.log(name)))}

correctly to this:

var greeting = function(chocolate)
{console.log(chocolate)};

and it told me to pass it a name, which I have, I called it chocolate, yet it still doesn't work and gives same error!


#2

@alaanor,

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


#3

@alaanor,
With your

var greeting = function(chocolate) {
    console.log(chocolate)
};

you have assigned an anonymous Function
to the variable greeting.

This anonymous Function takes 1 parameter chocolate

Within the FUNCTION-BODY of this anonymous Function
the chocolate parameter will be seen and used as a local variable.

If you want to call this anonymous Function
you will have to add a pair =parentheses= ( ) to the greeting variable
like

greeting();

but as the anonymous Function was defined as having 1 parameter chocolate
you will have to provide 1 argument in this case a =name= as a string Value
like

greeting("AlphaMikeEchoNovember");

PS. It might be that the Instructions require you to use a specific-output-string......


#4

When I attempt to input atleast 1 argument it states an error: SyntaxError: Unexpected identifier
This problem however does not appear when I do not have that 1 argument, also adding a pair of parentheses to the greeting variable just warps how greeting(); is taken and instead of greeting being blue, (before adding parentheses), it is now white, and it has an error saying Unexpected Token (
I haven't tried combining them, but I heavily suspect errors.
PS. It just says to pass greeting a name. It just states: Oops, try again. You did not call the greeting function. Pass it a name!


#5

@alaanor,
Present the code you are using which causes the SyntaxError: Unexpected identifier


#6

var greeting = function(chocolate)
greeting("chocolate")
{console.log(chocolate)};

If that's what you meant by the one argument. Also, changing what's in the quotation marks within the arguments change nothing.


#7

@alaanor,
I meant...

var greeting = function(chocolate)
{console.log(chocolate)};

greeting("aName");


#8

Thank you so much, I was so confused on this one.


#9

@alaanor,
Read through the Function talk....!!!