-2

我是编程新手,并且使用 codeademy 来帮助解决这个问题,如果这个问题有点明显,请原谅我。我主要希望能够调用一个函数。我已经复制并粘贴了下面的代码学院的东西,我主要想知道我必须做什么才能“调用问候功能”。如果你能准确地解释为什么要做什么,那就太好了。

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!`
4

4 回答 4

5

要调用问候功能,您需要做的就是:

greeting("My Name"); // will call the function and produce "Great to see you, My Name");
于 2013-08-15T17:49:41.653 回答
2

在javascript中,您调用这样的函数:

greeting("your name here");

一般来说,如果你有一个函数,语法是function(argument1, argument2, ...);

于 2013-08-15T17:49:28.287 回答
0

这些是基本的。通过谷歌的简单努力,你可以找到答案,但无论如何,你可以这样调用你的函数。

 greeting("your name");
于 2013-08-15T17:56:35.327 回答
0

我知道了。现在我知道如何调用函数了。我的答案是对的。

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

// On line 11, call the greeting function!
var greeting = function (name) {
    console.log("Great to see you," + " " + "Deneb");
};
greeting("Deneb");

要调用一个函数,我们总是需要输入“Greeting”、“myUser”等函数,然后给它函数参数。这就是我所做的。

于 2015-09-24T10:37:33.133 回答