Answers for "10.4.2. Parameters and Arguments¶ // Functions"

0

10.4.2. Parameters and Arguments¶ // Functions

/*The function hello takes a single value, which we expect to be a 
person's name, and returns a message that greets that person.*/

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

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

//Hello, Lamar!


/*In this example, name is a parameter. It is part of the function 
definition, and behaves like a variable that exists only within the
function.

The value "Lamar" that is used when we invoke the function on line 5 is
an argument. It is a specific value that is used during the function 
call.

The difference between a parameter and an argument is the same as that
between a variable and a value. A variable refers to a specific value,
just like a parameter refers to a specific argument when a function 
is called. Like a value, an argument is a concrete piece of data.*/
Posted by: Guest on June-24-2021

Code answers related to "10.4.2. Parameters and Arguments¶ // Functions"

Code answers related to "Javascript"

Browse Popular Code Answers by Language