Skip to content

Instantly share code, notes, and snippets.

@Aldhanekaa
Last active November 5, 2020 21:20
Show Gist options
  • Save Aldhanekaa/bbf62e70e4ff930a733659569ffbf2a6 to your computer and use it in GitHub Desktop.
Save Aldhanekaa/bbf62e70e4ff930a733659569ffbf2a6 to your computer and use it in GitHub Desktop.
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