You are here: Home / Topics / Return the Sum of Two Numbers in JavaScript

Return the Sum of Two Numbers in JavaScript

Filed under: JavaScript on 2023-08-06 20:33:00

Create a function that takes two numbers as arguments and returns their sum.

Examples

addition(3, 2) ➞ 5

addition(-3, -6) ➞ -9

addition(7, 3) ➞ 10

 

Code:

 

<script>

function addition(a, b){

return a+b;

}

 

addition(3, 2); //output 5

addition(-3, -6); //output -9

addition(7, 3); //output 10

</script>

About Author:
S
Shyam Dubey     View Profile
If you are good in any field. Just share your knowledge with others.