The collection.sum( ) method returns the sum for all values in the collection instance.
Only numerical elements are taken into account for the calculation (other element types are ignored).
If the collection contains objects, pass the propertyPath parameter to indicate the object property to take into account.
collection.sum( ) returns 0 if:
- the collection is empty,
- the collection does not contain numerical elements,
- propertyPath is not found in the collection.