Answers for "how to get an average of an array of numbers javascript"

CSS
3

javascript average of numbers in array

const scores = [ 20, 50, 75, 100, 115 ];
let total = 0;

for ( let i = 0; i < scores.length; i++ ) {
  total += scores[i];
}

console.log( total / scores.length );
Posted by: Guest on September-05-2021
-2

Get the Average of an Array of Number

const average = (...array) => array.reduce((a, b) => a + b) / array.length

average(21, 56, 23, 122, 67)
//57.8
Posted by: Guest on April-14-2022

Code answers related to "how to get an average of an array of numbers javascript"

Browse Popular Code Answers by Language