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

15 lines
415 B
JavaScript

export function sum(values) {
// implementar logica aqui
if (toString.call(values) !== "[object Array]")
return false;
var total = 0;
for(var i=0;i<values.length;i++)
{
if(isNaN(values[i])){
continue;
}
total += Number(values[i]);
}
return total;
}