使用参数在函数内部传递的值

时间:2017-05-21 20:24:23

标签: javascript

我正在尝试编写一个带变量inputString的函数,然后将其记录在控制台中,但是不成功。

function processData(inputString) {
    // This line of code prints the first line of output
    console.log("Hello, World.");

    // Write the second line of output that prints the contents of 'inputString' here.

    console.log(inputString);
} 

processData("Welcome to 30 Days of Code!");


Your code did not pass this test case.
Input (stdin)
Welcome to 30 Days of Code!
Your Output (stdout)
Hello, World.
Welcome to 30 Days of Code!
Hello, World.
Welcome to 30 Days of Code!
Expected Output
Hello, World.
Welcome to 30 Days of Code!
Compiler Message
Wrong Answer

2 个答案:

答案 0 :(得分:2)

在您使用它的网站上已调用函数processData(inputString)来测试函数,无需再次调用它

function processData(inputString) {
    // This line of code prints the first line of output
    console.log("Hello, World.");
    // Write the second line of output that prints the contents of 'inputString' here.
    console.log(inputString);
} 

您的代码没有问题。

希望这有帮助!

答案 1 :(得分:0)

我认为问题是要这样做:

console.log("Hello, World.");
console.log("Welcome to 30 Days of Code!");

在JavaScript中,\ n创建一个新行。