settingsAccountsettings
Menusettings

Q: How to multiply two numbers in JavaScript

+6 votes

Write a JS function that calculates the product of two numbers. The input comes as two number arguments. The output should be the returned as a result of your function.

Examples:

Input:
3
2    

Output:
6


Input:
23632.36
-12.3249    

Output:
-291266.473764

asked in JavaScript category by user richard8502

3 Answers

+5 votes

Here's my solution:

function multiplyTwoNumbers(a, b) {
    let result = a * b;
    console.log(result);
}

multiplyTwoNumbers(2, 3);

 

answered by user andrew
+3 votes

My code:

function mult(nums) {
    let result = Number(nums[0]) * Number(nums[1]);
    console.log(result);
}

mult(["23632.36", "-12.3249"]);

 

answered by user eiorgert
+2 votes
function mNumbers([num1,num2]) {
    console.log(num1 * num2);
}

mNumbers(["5", "7"]);
answered by user hues
...