Noroff-Education
5/13/2020 - 1:53 PM

Add two numbers with a function

function addNumbers(numberOne, numberTwo){
  var total = numberOne + numberTwo;
  console.log(total);
}

Adding two numbers with a function

  1. We use the function keyword to create a function and we set the name to be addNumbers. We set the parameter names numberOne and numberTwo
  2. We create a new variable called total, and set it to be the value of numberOn plus numberTwo
  3. We log out the total we've created.