JavaScript Program to Calculate the Average of All the Elements Present in an Array
Given an array "arr" of size N, the task is to calculate the average of all the elements of the given array. Example: Input: arr = {1, 2, 3, 4, 5}Output: 3Explanation: (1+2+3+4+5) / 5 = 15/5 = 3These are the following approaches: Table of Content Using for loopUsing a while loopUsing reduce() method