I can't see why this function is returning undefined:
function sumArray(array) {
array.reduce(function(result, item) {
return result + item;
})
}
array = [1,2,3]
sumArray(array)
I've tried something similar and it works ok (below), so I'm not sure if it's specific to the parameter being an array?
function sayNumber(num) {
return num + 1;
}
num = 1
sayNumber(num)
sumArraydoesn't return anything.