The sum of values in an array. If the array parameter value is
an empty array, returns zero.
arraySum(array)
→ returns numeric
someArray.sum()
false
Uses the arraySum function to get sum of values in an array
numberArray = [10,99,27,72];
writeOutput( arraySum(numberArray));
Expected Result: 208
To get sum of values in an empty array
numberArray = [];
writeOutput( arraySum(numberArray));
Expected Result: 0
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
Signup for cfbreak
to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.