Where do I belong topic

Tell us what’s happening:

this sort function is not function is not working!!what should I do now?

Your code so far

function getIndexToIns(arr, num) {
  // Find my place in this sorted array.
 var a= arr.sort();

  return a;

getIndexToIns([7, 3, 20, 3], 5);

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0.

Link to the challenge:

I think you need a compare function https://www.w3schools.com/jsref/jsref_sort.asp

It’s a little more involved than just sorting the given array. You have to first get num into the array, then sort it, then find the index of where num ended up in the sorted array. Which does include needing a compare function like @JohnnyBizzel mentioned.

1 Like