const arr = [5,6,0,7,8]; const sum = (arr,num) => arr.reduce((total)=>(num==0 ? total : total+num), 0) console.log(sum(arr, 0))
Please check how
You need parenthesis to execute the function ()
()
sum(arr, 0)
Without parenthesis you store a reference to the function in the variable