Functions 3/13


#1

What is wrong with this syntax? Please Help!

// Below is the greeting function!
// See line 7
// We can join strings together using the plus sign (+)
// See the hint for more details about how this works.

var sayHello = function (Ana) {
    console.log("Great to see you," + " " + "Ana");
};

// On line 11, call the greeting function!
sayHello("Ana");

#2

The syntax seems to be ok, it just doesn't make much sense how you used your parameter.
The idea is that you declare a local variable here:

var sayHello = function (Ana) {

which you named Ana and give a value to this variable by adding a value (called argument) here:

sayHello("Ana");

So you far so good. Now what should happen is that e.g.

sayHello("Ana")
sayHello("haxor")
sayHello("Mr. Spock")

should result in:

Great to see you, Ana
Great to see you, haxor
Great to see you, Mr. Spock

So the powerful idea is that you can use the same function but by changing the input you change the output. Now what you did is instead of using Ana (the variable) you hard coded "Ana" the string. So no matter what the input is you'll always get:

Great to see you, Ana

Hope this explains it a bit.


#3

I did this:

var greeting = function (name) {
console.log("Great to see you," + " " + name);
};
greeting("Jonathan");
That is because the variable "greeting" has the "Great to see you," + " " + name". The function makes it activate. You enter you name into the name slot.
Hope that made sense.


#4

Ps. Your syntax error is the bolded"
// Below is the greeting function!
// See line 7
// We can join strings together using the plus sign (+)
// See the hint for more details about how this works.

var sayHello = function (Ana) {
console.log("Great to see you," + " " + "Ana");
};

// On line 11, call the greeting function!
*sayHello("Ana");
For the bolded it is name not your name yet. Great job at the rest!


#5

I Still need a greeting function how do you do that


#6

Thank you for your reply :smile:


#7

Thank you, you helped a lot :relaxed: