Answers for "10.4.2. Functions // Default Value"

0

10.4.2. Functions // Default Value

/*This example modifies the hello function to use a default value for 
name. If name is not defined when hello is called, it will use the 
default value.*/

function hello(name = "World") {
   return `Hello, ${name}!`;
}

console.log(hello());
console.log(hello("Lamar"));

//Hello, World!
//Hello, Lamar!
Posted by: Guest on June-24-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language