How to correctly write a function that is a greeting?

时间:2019-04-16 22:20:25

标签: javascript function

I am creating a function that returns a personalized greeting but when I go to return the function it says I pass 1 out of 4 test

Here is the code:

function greeting('Omari'){
  console.log('Hello')
}
 greeting();

1 个答案:

答案 0 :(得分:0)

Make your code ask for a name with prompt(). Then write a function that takes a parameter name and return a greeting:

 

function greeting(name) {
return "Hello, " + name + "!";
}

var myName = prompt("What's your name?");
alert(greeting(myName));