Calculates the average of the values in an array.
All elements in the array must contain values that can be
automatically converted to numeric.
arrayAvg(array)
→ returns numeric
someArray.avg()
Uses the arrayAvg function to get average value of an array
numberArray = [1,2,3];
writeOutput(arrayAvg(numberArray));
Expected Result: 2
CF 11+ Lucee 4.5+ Uses the avg member function is the same as running arrayAvg.
numberArray = [1,2,3];
writeOutput(numberArray.avg());
Expected Result: 2
Signup for cfbreak
to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.