settingsAccountsettings
By using our mini forum, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy
Menusettings

Q: Function to Sum 3 Numbers in JavaScript

+2 votes

Write a JS function that takes three numbers as input and outputs their sum.

The input comes as three number arguments passed to your function.

The output should be printed to the console.

Examples:

Input: 2, 3, 4    

Output: 9

Input: 1.5, 1.5, -1    

Output: 2
 

asked in JavaScript category by user eiorgert

1 Answer

+1 vote
 
Best answer

Here's my code:

function sumNumbers(a, b, c) {

    var sum = a + b + c;

    console.log(sum);
}

sumNumbers(1, 2, 3);

//sumNumbers(-1, -2, -3);
// -6

//sumNumbers(2.5, 3.5, -1);
// 5

 

answered by user hues
edited by user golearnweb
...