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

17 lines
352 B
JavaScript

export function sum(values) {
// implementar logica aqui
let soma = 0;
if(values.length == 1){
for(let i = 0; i < values.length; i++){
soma = values[i];
}
return soma;
}else if(values.length == []){
return soma = 0;
}else{
for(let i = 0; i < values.length; i++){
soma += values[i];
}
return soma;
}
}