Trying to multiply all the elements of array A, however, with values [1,2,0,-5], it should return 0 but it actually returns 1. What mistake am I making? Here is the code:
function solution(A){
let multi = 1;
for(i = 1; i < A.length; i++){
multi *= A[i]
}
if(multi == 30){
return 1
} else if (multi == -30){
return -1
} else if (multi == 0){
return 0
} else{
console.log("hey hey");
}
}
solution(A = [1,2,0,-5])