[Solved] How to multiply two numbers in JavaScript

  

3
Topic starter

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

1 Answer
2

Here are some solutions:

function multiplyTwoNumbers(a, b) {
    let result = a * b;
    console.log(result);
}
 
multiplyTwoNumbers(2, 3);
function mult(nums) {
    let result = Number(nums[0]) * Number(nums[1]);
    console.log(result);
}
 
mult(["23632.36", "-12.3249"]);
function mNumbers([num1,num2]) {
    console.log(num1 * num2);
}
 
mNumbers(["5", "7"]);
Share: