Description

Calculates the average of the values in an array.

Returns

Number. If the array parameter value is an empty array, returns zero.

Category

Function syntax

ArrayAvg(array)

See also

ArraySumBasic array techniques in the Developing ColdFusion Applications

Parameters

Parameter

Description

array

(Required) The array containing the values.

Usage

The following example uses the ArrayAvg function to get the average value of an array.

Example

<cfscript>
       myArray=[1,2,3,4,5,5.5,6,7,8,9];
       writeOutput(ArrayAvg(myArray)); // returns 5.05
</cfscript>

Output

5.05

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy