Skip to content

Instantly share code, notes, and snippets.

@lhuria94
Created January 2, 2018 13:12
Show Gist options
  • Save lhuria94/64eb7a8c5b04437940d848f038aec4dd to your computer and use it in GitHub Desktop.
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.
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