function getIndexToIns(arr, num) {
// Find my place in this sorted array.
arr.push(num); // i want to make it array.
for(var i =0;i<arr.length;i++){ /// then rearrange it .
if (arr[i]>arr[i+1]){
arr[i] = arr[i+1];
arr[i+1]= arr[i];
}
return arr;
}
return arr.indexOf(num); then get it index
}
getIndexToIns([40, 60], 50);
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/where-do-i-belong