js multiply array code example

Example 1: multiply js

const multiply = (x,y)=>{
if(x==1){ return y;}
else if(x>1){
return y +multiply(x-1,y)
}
else throw "Not Numbers"
}
var result = multiply(4,3);
console.log(result)

Example 2: javascript multiply array with scalar

var input = [3, 6, 4];
var scalar = 5;
var output = input.map(x => x * scalar); // [15, 30, 20]

Example 3: multiply function javascript

// MULTIPLY FUNCTION
const multiply = (num1, num2) => {
  return num1 * num2;
};
let resulMultiply = multiply(4, 5);
console.log(resulMultiply);
// 20

Tags:

Html Example