Finding minimum and maximum sum of the given integer array

Algorithm

  1. Sort the given array in an ascending order
  2. Add the element from 1st position to length, which is the maximum sum of the given integer array.
  3. Add the element from 0th position to length — 1, which is the minimum sum of the given integer array.

Code(JavaScript)