Created
January 2, 2018 13:12
-
-
Save lhuria94/64eb7a8c5b04437940d848f038aec4dd to your computer and use it in GitHub Desktop.
As a part of this Kata, you need to create a function that when provided with a triplet, returns the index of the numerical element that lies between the other two elements.
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
var gimme = function (inputArray) { | |
// Clone the input array. | |
var clonedArray = inputArray.slice(0); | |
// Sort it in ascending order. | |
clonedArray.sort(function(a, b){ | |
return a-b | |
}); | |
return inputArray.indexOf(clonedArray[1]); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment