I am trying to sum all odd numbers of an array. The following method does not work and returns NaN. Could someone explain me why? I found a workaround so I do not need an alternative code. It would be great if you could explain me why (a supposed number)%2 is NaN. Thanks a lot. (I have just started learning Javascript. So sorry if this is ... )
let arr=[1,2,3,4,5,6,7]
let result = arr.reduce((accumulator, currentValue) => {
if (currentValue%2 >0){
return accumulator + currentValue}})
console.log(result)