Get multiplication in javascript using array input

There are lots of method available in javascript to get the multiplication. But here we have to pass the array value as arguments to call the function. In that case we can use spread operator in javascript

Answers 1
  • Pass array as arguments to multiply function using spread operator

    function multiply(number1, number2, number3) {
      console.log(number1 * number2 * number3);
    let numbers = [1,2,3];



    This code snippet retuns the multiplication of the input parameters which is passed as array to function using spread operator. You have to pass the number of array elements which is equal to the number of parameters listed in the function definition.

  • Back to code snippet queries related javascript