arraySum

The sum of values in an array. If the array parameter value is
an empty array, returns zero.

arraySum(array) → returns Numeric

Member Function Syntax

someArray.sum()

Argument Reference for the arraySum function

array

Required: Yes
An array name or variable name

Examples sample code invoking the arraySum function


Sum of values in an array

Uses the arraySum function to get sum of values in an array

numberArray = [10,99,27,72];
writeOutput( arraySum(numberArray));

Expected Result: 208


Sum of values in an array

To get sum of values in an empty array

numberArray = [];
writeOutput( arraySum(numberArray));

Expected Result: 0


Sum of values in an array

CF 11+ Lucee 4.5+ Uses the sum member function is the same as running arraySum.

numberArray = [10,99,27,72];
writeOutput( numberArray.sum() );

Expected Result: 208


Fork me on GitHub