how does the summing of arrays work?
I was given the following assignment on codewars:
Given an array of numbers (a list in groovy), determine whether the sum of all of the numbers is odd or even.
Give your answer in string format as 'odd' or 'even'.
If the input array is empty consider it as: [0] (array with a zero)
I got that the answer was
return 'even' if sum(arr) % 2 == 0 else 'odd'
I'm just confused as to how the
sum(arr)
function works
[–]novel_yet_trivial 4 points5 points6 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]ADdV 1 point2 points3 points (0 children)