Function Syntax


#1


https://www.codecademy.com/courses/javascript-beginner-en-6LzGd/0/3?curriculum_id=506324b3a7dffd00020bf661


The code just says that there is something wrong with my syntax. It also states that there is an unexpected string. I don't understand what exactly is wrong.


// 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 greeting = function (name) {
    console.log("Great to see you," + " " + name);
};

// On line 11, call the greeting function!
var sayHello = function("Alexa") {
    console.log('Hello ' + "Alexa");
};


#3

This is not the same as calling a function. To call a function, just write the function name followed by parentheses. If the function takes an argument, pass it one.

Ex:

function(argument);

So to call the greeting function, you would write greeting and pass an argument into the parentheses. In this case, the argument would be a text string.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.