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 'n'th negative number. Array 'nums' can be any length, including length zero. Each number could be positive, negative, or zero. All numbers are included in the sum up to, but not including, the 'n'th negative number. There could be fewer than 'n' negative numbers, in which case the result should be the sum of all the numbers in the array. Look at the test data for examples. test2022_12_08_P1SLHL_sumUntilNthNeg([3, 7, 0, 2, 1, 4, 0, 7, -2, 4], 1) → 24 test2022_12_08_P1SLHL_sumUntilNthNeg([], 7) → 0 test2022_12_08_P1SLHL_sumUntilNthNeg([-5], 1) → 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: 240
Copyright Nick Parlante 2017 - privacy