Where do I Belong -- where am I wrong

Tell us what’s happening:

Your code so far

function getIndexToIns(arr, num) {
  let arr1 = arr.sort(function(a,b){return a-b});
  let j;
  for(let i=0;i>arr1.length;i++){
      return i;

getIndexToIns([40, 60], 50);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0.

Link to the challenge:

Hello Ateet,

you can use console.log() at any place on your code for debugging, to make sure you reach a point in your code or not.

Please note, your loop never begins! This is becasue i starts from 0, and it’s never will be greater than array length, so I assume you got a typo/mistake by typing > instead of <

Another bug is when for loops ends! but there is no any respond after the loop!? considering getIndexToIns([2, 5, 10], 15) that you won’t find any place for the 15, so once the loop is finished, it should return 3. Go for it, fix it.

Keep going on great work, happy programming.

hi @NULL_dev, I noticed that when I try console.log I don’t get any results that I can view. Where should the log go to?

Hello hbar1st
I think this could be a bug with FCC, not sure.
I always use the dev tool of the browser for checking the console logs, you can open the dev tool in chrome with ctrl+shift+I

1 Like