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

7 lines
160 B
JavaScript
Raw Permalink Normal View History

export function sum(values) {
2022-11-02 21:04:26 +00:00
if (values.length == 0) return 0;
const val = values.reduce((accumulator, value) => accumulator + value, 0);
return val;
}