challenge-algorithms-v2.0-w.../06-sum/index.js

11 lines
147 B
JavaScript

export function sum(values) {
if (values.length) {
return values.reduce(function (soma, i) {
return soma + i
})
}
return 0
}