JS参数与参数

时间:2019-04-10 10:48:16

标签: javascript function parameters console.log

请帮助我进行练习,由于某些原因,我的代码无法正常工作,并且无法成功运行。

// Exercise One: 
// Step One: Create a function called 'parametersExercise'. 
// Step Two: This function will need to take two parameters, call them 'param1' and 'param2'
// Step Three: The function should console log the second parameter.


// DO NOT CHANGE ANYTHING ON THE NEXT FOUR LINES!
function exerciseTwo(){
  function sayMyName(parameter1){
    console.log(parameter1);
  }


// Continue below this line:

**下面的代码是否准确?

 function parametersExercise(param1, param2){

 console.log(param2);
 }



// Exercise Two:
// Step One create a variable called 'myName' and assign it the a string of your name.
// Step Two: Call the function called "sayMyName",passing the 'myName' variable as it's only argument.
// NOTE: You do NOT need to create the function (sayMyName), doing so will break the test. 
//       It has been created for you.
let myName = "Juell";
sayMyName(myName);

console.log();

}

1 个答案:

答案 0 :(得分:0)

我只是这样做,并且摆脱了上一个console.log,并将let更改为var。所以,这是您要做的部分:

var myName =“您的名字”; sayMyName(myName);