Campaign/Level 1 of 12
easyLoops1 bug

The Missing Last Element

Your first ticket: the cart total is always a bit too low.

sumArray(nums) should return the sum of every number in the array.

Fix the code so every test passes. Keep the function name sumArray.

Test cases

  • sumArray([1,2,3]) → 6
  • sumArray([10]) → 10
  • sumArray([]) → 0
  • sumArray([-2,5,4]) → 7

Hints

each hint costs XP

Stuck? Hints go from a nudge to the exact fix.