In last part of function we learn about a basic function and we just console.log inside the function but today we are going to learn more about it. We’ll learn how we can add two numbers using a function!

In last part we didn’t use any parameters right? Now we’ll use some parameters.

We’ll pass the parameters inside of “()”. We can pass variables here, even function too. But for now just think of variable.

Today we’re going to create a plus function which will give us the result of two number.

First we’re going to write function keyword and the name of function and we’ll pass two numbers.

function plus(number1,number2){

We can easily access the values from the parameters. Now we can store both in a variable like –

function plus(number1,number2){
  var total = number1 + number2

Now we can console log it on our console.

See the result

Can you write the minus function now ?

See the codes –

Find me on social media – twitter, linkedin

Leave a Reply

Your email address will not be published. Required fields are marked *