Blog

In JavaScript Find the Average of the Sum of All Elements in an Array
Posted on June 3, 2015 in Algorithms, JavaScript by Matt Jennings

var x = [3, 9, 6];
var sum = 0;

for(var i = 0; i < x.length; i++) {
    sum += x[i];
}

console.log(sum / x.length);

Leave a Reply