Answers for "js average value of array"

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
0

javascript calculate average of array

const sum = times.reduce((a, b) => a + b, 0);
const avg = (sum / times.length) || 0;

console.log(`The sum is: ${sum}. The average is: ${avg}.`);
Posted by: Guest on December-01-2021

Browse Popular Code Answers by Language