You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create a function that returns the average of an array of numbers ("scores"), rounded to the nearest whole number. You are not allowed to use any loops (including for, for/in, while, and do/while loops). The array will never be empty.
*/
/*
function average(score) {
let sum = score.reduce((acc,c)=>acc+c,0);
let numOfScores = score.length;
let average = Math.round(sum / numOfScores);
return average;
} */
// more concise function
const average = score => Math.round(score.reduce((acc,c)=>acc+c,0)/score.length);