I am starting a new mini series on JavaScript. I’m starting it from zero. Anyone can start learning from here. My goal is helping others while learning! I know about JavaScript and I’m working on a MERN tech stack. But I think it is not a bad idea to revise the JavaScript from scratch and helping others in this time. If you have any questions, shoot on the comment session or you can directly ask me in my social media. Social media links are in the last part of today’s lesson! Let’s learn JavaScript together.

More About Functions — JavaScript Series — Part 17

A full series to learn the JavaScript from zero

Muhammad Ali
2 min readFeb 10, 2020

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){
console.log(number1)
console.log(number2)
}
plus(10,12)

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 ?

Originally it published on nerdjfpb blog. Check the git for codes.

you can connect with me in twitter, linkedin or instagram

--

--

Muhammad Ali
Muhammad Ali

Written by Muhammad Ali

An otaku who loves computer. Love to write and help others through my work. Have a look on my Instagram https://www.instagram.com/nerd_jfpb/

No responses yet