programming-examples/js/Array/Write a JavaScript program to find the sum of squares of a numeric vector..js
2019-11-15 12:59:38 +01:00

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]));