Last active
September 23, 2017 23:06
-
-
Save andreytwostep/961fb77b7acab4e618bb33eca2a4d244 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function arrayPairSum(nums) { | |
var sum = 0; | |
if (nums !== null && nums.length > 1) { | |
nums.sort(); | |
for (var i = 0; i < nums.length; i += 2) { | |
sum += nums[i]; | |
} | |
} | |
return sum; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment