Using array.reduce functions to simplify the sum methods