Array Average Value
Tuesday April 22, 2008
If we have an array of numbers in JavaScript, how can we determine the average?
While getting the maximum and minimum values from an array does not depend on the array contents being of any particular type, calculating the average depends on the content either being numbers or being able to be converted into numbers. Here's how to add a method to your arrays to allow the average value to be retrieved that will ignore any values in the array that can't be converted into a number.
Array Average Value


Comments
No comments yet. Leave a Comment