Answers for "js how to get averga of array"

CSS
2

average of an array js

const avg = arr => {
  const sum = arr.reduce((acc, cur) => acc + cur);
  const average = sum/arr.length;
  return average;
}

console.log(avg([1, 2, 3, 7, 8]));
Posted by: Guest on February-29-2020
2

getting average of array javascript

var total = 0;
for(var i = 0; i < grades.length; i++) {
    total += grades[i];
}
var avg = total / grades.length;
Posted by: Guest on February-08-2021

Code answers related to "js how to get averga of array"

Browse Popular Code Answers by Language