Created
March 3, 2017 07:46
-
-
Save Underdoge/8b5ca82cfe25adaae4d9df410414b44f to your computer and use it in GitHub Desktop.
arrayMaximalAdjacentDifference
This file contains hidden or 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 arrayMaximalAdjacentDifference(inputArray) { | |
return inputArray.reduce(function(acc,currval,currind,arr){ | |
if(Math.max(currval,arr[currind+1])-Math.min(currval,arr[currind+1])>acc) | |
acc=Math.max(currval,arr[currind+1])-Math.min(currval,arr[currind+1]); | |
return acc; | |
},0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment