The input given to a function is called a parameter.
A function can take more than one parameter:
function add(a, b) {
return a + b;
}When you write a function (sometimes called declaring a function) you assign names to the parameters inside of the parentheses (()). Parameters can be called anything.
This function is exactly the same as the on above:
function add(num1, num2) {
return num1 + num2;
}- Write a function that multiplies two numbers together
12
- From scratch, write a function that divides two numbers
0.75
- Write a function that takes a name (a string) and returns a greeting
Hello, my name is Daniel
- Write a function that adds two numbers together
- Call the function, passing
13and124as parameters, and assigning the returned value to a variablesum
137
- Write a function that takes a name (a string) and an age (a number) and returns a greeting (a string)
## Expected result
Hello, my name is Daniel and I'm 30 years old