Solution 1 Error?

Tell us what’s happening:
Does anyone realize solution 1 works and passes until you test it (console,log) it on the last few tests? then it doesn’t even run. Is this solution wrong?
also, can anyone explain why the function must return arr.length?

Your code so far

function getIndexToIns(arr, num) {
  return a-b
for (let i = 0; i < arr.length; i++){
  if (arr[i] >= num)
  return i
return arr.length

console.log(getIndexToIns(getIndexToIns([], 1));

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36.

Challenge: Where do I Belong

Link to the challenge:

This is not a valid use of the function

maybe check again this line, are you sure there is written what you want there to be written?

1 Like

As said, you are calling getIndexToIns twice in console.log (passing its return it itself and missing a )).

Try removing the array length return and look at what tests are failing, see if you can figure out for what/how it is used.

1 Like