Created
February 18, 2017 23:40
-
-
Save tdlm/56c230879ae9b4d98d1d13ed2b3dce23 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
const sumArray = (a) => { | |
if ( typeof a == 'undefined' || !a || a.length < 2 ) { return 0; } | |
a.sort((a,b) => a - b).splice(0, 1) | |
a.splice(a.length - 1, 1); | |
if ( a.length < 3 ) { return 0; } | |
return a.reduce((a,b) => a+b); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment