Answers for "average formula for javascript"

1

calculate average javascript

var sum = array.reduce((a, b) => a + b, 0);	//get sum of all elements in array
var avg = (sum / array.length) || 0; //get average of all elements in array ;)
Posted by: Guest on October-10-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

Code answers related to "average formula for javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language