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:
M
Mr. Dubey     View Profile
Founder of MCQ Buddy. I just like to help others. This portal helps students in getting study material free. Share your stuff here so that others can get benefitted.