Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

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;
}

Exercise

  • Write a function that multiplies two numbers together

Expected result

12

Exercise 2

  • From scratch, write a function that divides two numbers

Expected result

0.75

Exercise 3

  • Write a function that takes a name (a string) and returns a greeting

Expected result

Hello, my name is Daniel

Exercise 4

  • Write a function that adds two numbers together
  • Call the function, passing 13 and 124 as parameters, and assigning the returned value to a variable sum

Expected result

137

Exercise 5

  • 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