reduced an array to a single number by multiplication of all numbers, but i get the wrong output
let numbs = [1, 2, 3, 4, 5, 6, 7, 8];
let reducedNumb = numbs.reduce((prevVal, currVal)=>
prevVal * currVal
,0)
console.log(reducedNumb); //output is 0
>Solution :
Simple math mistake. Something times 0 is always 0 😉
let reducedNumb = numbs.reduce((prevVal, currVal)=> prevVal * currVal ,1)