Answer:
Following are the program in the JavaScript Language.
//define function
function greeting(name)
{
//set string type object
put = "Hello"
//set the if conditional statement
if (name) {
//concatenate with the object
put += ", "+name;
}
//concatenate "!" with object
put += "!";
console.log(put);
}
console.log(new greeting("Charlotte"));
Output:
Hello, Charlotte!
Step-by-step explanation:
In the following program, Firstly we set a function "greeting" and pass an argument "name", inside the function.
- Set a string type object "put" and initialize to "Hello" in it.
- Set the if conditional statement to check the the argument "name" and concatenate the value of the "name" before "Hello".
- Then, concatenate "!" after the "Hello" in name and print the object "put".
Finally, we call the function "greeting" through the pre-defined function "console.log()" by passing the sting inside the parameter.