Answers for "filter array and get index of num"

0

filter array and get index of num

function getIndexToIns(arr, num) {
  arr.sort((a, b) => a - b);

  for (let i = 0; i < arr.length; i++) {
    if (arr[i] >= num)
      return i;
  }

  return arr.length;
}
Posted by: Guest on September-04-2021
0

filter array and get index of num

function getIndexToIns(arr, num) {
  return arr.filter(val => num > val).length;
}
Posted by: Guest on September-04-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language