Finding the average and the median of an array using JavaScript can be a fairly painless process. If you do it right, it should only take a few lines of code to calculate the correct averages and medians for any given array. The average, which is the sum of all the values divided by the …