Created
December 16, 2016 08:18
-
-
Save Hoxtygen/33f8c4a6cf4e8fd968e49c41265a4201 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
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