about | help | code help+videos | done | prefs |
Write a method that returns the sum of all the numbers in array 'nums' up to but not including the first negative number. Array 'nums' can be any length, including length zero. The first number could be negative, in which case the sum is zero. All numbers could be non-negative, in which case the result should be the sum of all the numbers in the array. Look at the test data for examples. da2022_11_10_sumUntilNeg([3, 7, 0, 2, 1, 4, 0, 7, -2, 4]) → 24 da2022_11_10_sumUntilNeg([]) → 0 da2022_11_10_sumUntilNeg([-5]) → 0 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 230
Copyright Nick Parlante 2017 - privacy