Last active
November 5, 2020 21:20
-
-
Save Aldhanekaa/bbf62e70e4ff930a733659569ffbf2a6 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) { | |
let result; | |
if (arr.indexOf(num) == -1) { | |
let N = Math.min(...arr.filter(e => e > num)); | |
console.log(N); | |
N = arr.indexOf(N) | |
console.log(N) | |
result = N; | |
// console.log(arr.indexOf(r)) | |
}else { | |
result = arr.indexOf(num) | |
} | |
return result; | |
} | |
console.log(getIndexToIns([40, 60], 50)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment