about | help | code help+videos | done | prefs |
Write a method that returns the sum of the numbers in the 'nums' array, but only include a number from 'nums' if the corresponding position in 'good' is 'true'. Note that the 'good' array might be shorter than the 'nums' array. If there is no corresponding location in the 'good' array, it can't have the value 'true' so you don't include that number. As a precondition, you may assume that the length of 'good' is less than or equal to the length of 'nums'. test2022_09_12_SLHL_addIfGood([55], [false]) → 0 test2022_09_12_SLHL_addIfGood([55], [true]) → 55 test2022_09_12_SLHL_addIfGood([1, 2, 3, 4, 5, 6, 7], [false, false, false, true, false, true, false]) → 10 ...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: 220
Copyright Nick Parlante 2017 - privacy