Parameters and Return Values

👨‍💼 Functions become much more powerful when they can receive input and produce output.
  • Parameters are variables that receive values when the function is called
  • Return values let functions send data back to the caller
The syntax:
function add(a, b) {
	return a + b
}

const result = add(5, 3) // result is 8
🐨 Open and:
  1. Create a function greetPerson that takes a name parameter and returns a greeting string like "Hello, [name]!"
  2. Create a function multiply that takes two numbers and returns their product
  3. Create a function isEven that takes a number and returns true if even, false if odd
  4. Call each function and log the results
💰 Remember: return stops the function and sends back a value. Without return, functions return undefined.

Please set the playground first