3. Function syntax


#1

I don't know what I'm doing wrong..

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


#2

Did you copy and paste your code?


#3

I am pretty sure I did


#4

Okay Great.I just had to make sure you got the exact code.


#5

In the () after the function keyword, when you use something inside of them it must be the name of a variable (called parameter). This will declare a local variable in the function by this name and you can assign values to this variable from outside of the function by passing values (called arguments) in the function call as you did here:

greeting("Elizabeth")

So better use e.g.:

var greeting = function (name) {

instead and use name inside of the function as an alias for your value. Thereby you could call the function with any name and you'll always get an appropriate response not only for "Elizabeth".


#6

Okay I guess you can handle it then...


#7

There's no problem with that! We're all here to help, you know? :wink:


#8

hey do you guys know how to do this?


#9

can someone copy and paste code?


#10

this function stuff is confusing


#11

We can't copy and paste the code thats against the rules but, admittedly this is one of the more easier topics of this course, if you're having difficult with this I would recommend going back, and redoing things till you understand why you're doing it.

Start by using and go from there.

var greeting = function(name) {

}

#12

Can someone tell me what's wrong ?

var saludo = function(nombre) {
console.log("Qué bueno verte" + "Silvia");
};


#13

you don't put console.log in the curly brackets look at this


#14

whoops just look at this
var greeting = function(name){console.log("Hello "+"name");};


#15

maybe its because your using spanish


#16

Could you post the link to the spanish exercise? Maybe the tasks are a little different idk.
Also you're not using the parameter nombre but instead use the hardcoded string "Silvia" same for you @tarikjaber your greeting function would print "Hello name" instead of "Hello YOURINPUT".


#17

Hi, I tried in Spanish and English, that´s my code, and it´s wrong, anybody can help me?

var saludo = function (name) {
console.log("Qué bueno verte," + " " + "Jose");
};


#18

Should be

console.log("Qué bueno verte," + " " + name);

This is the same for everybody else who had this problem.


#19

Can anyone tell me the exact code , please? It is still not fixed


#20

We're not allowed to give you full code. Against CC policy.