9 lines
190 B
JavaScript
9 lines
190 B
JavaScript
|
function sum_sq(array) {
|
||
|
var sum = 0,
|
||
|
i = array.length;
|
||
|
while (i--)
|
||
|
sum += Math.pow(array[i], 2);
|
||
|
return sum;
|
||
|
}
|
||
|
|
||
|
console.log(sum_sq([0,1,2,3,4]));
|