about | help | code help+videos | done | prefs |
Write a method that accepts a non-empty array of integers. Find the sum of all the positive integers in the array. Also find the sum of all the negative integers in the array. Return whichever of these sums is farthest from zero. If they are both the same distance from zero, return zero. fromZero([5, 7, 2, 1, -4, -6, 3]) → 18 fromZero([-5]) → -5 fromZero([0, 0, 0, 0]) → 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: 350
Copyright Nick Parlante 2017 - privacy