challenge-algorithms-v2.0-c.../06-sum/index.js
2022-10-30 19:37:14 -03:00

8 lines
250 B
JavaScript

export function sum(values) {
// implementar logica aqui
let total = 0
for (let i = 0; i < values.length; i++) {
total += values[i]; // adiciona o valor do indice (que aumenta com o loop) no total
}
return total // torna values = total
}