Skip to content

Instantly share code, notes, and snippets.

@Hoxtygen
Created December 16, 2016 08:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hoxtygen/33f8c4a6cf4e8fd968e49c41265a4201 to your computer and use it in GitHub Desktop.
Save Hoxtygen/33f8c4a6cf4e8fd968e49c41265a4201 to your computer and use it in GitHub Desktop.
function getIndexToIns(arr, num) {
//Add the value of num to the array
arr.push(num);
//Sort the array
arr.sort(function(a, b) {
return a-b;
});
//Get the index of value num
arr = arr.indexOf(num);
return arr;
}
getIndexToIns([40, 60], 50);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment