let arr = [1, 9, 3, 4, 5, 6];
methods1:
function multiply1(arrary) {
if (arrary instanceof Array) {
let result = arrary.length > 0 ? 1 : null;
if (arrary.indexOf(0) > 0) {
return result = 0;
}
for (let i = 0; i < arrary.length; i++) {
result *= arrary[i];
}
return result;
}
return null;
}
console.log(multiply(arr));
methods2:
function multiply2(arrary) {
if (arrary instanceof Array){
return arrary.reduce(function(a,b){
return a*b;
})
}
}
console.log(multiply2(arr));