Total of a list
Write sum(nums)
Return the total of an array of numbers. An empty array totals 0. Numbers can be negative or have decimals.
Examples
sum([1, 2, 3])returns6sum([10, -4])returns6sum([])returns0
Plus 5 hidden tests with edge cases. Their inputs stay hidden until you have tried twice.
Tab indents, Ctrl+Enter or Cmd+Enter runs the tests.
Run tests to see each example and hidden test pass or fail. Each run stops after 3 seconds.