Find the Average of an Array using node js

// Function to find the average of an array
function findAverage(arr) {
  const sum = arr.reduce((acc, num) => acc + num, 0);
  return sum / arr.length;
}

// Example usage
const numbers = [10, 5, 8, 15, 3];
const average = findAverage(numbers);
console.log(average);

 

Post your Answer