Freecodecamp: Rewrite of "Where do I belong" instructions

Created on 3 Jun 2016  路  6Comments  路  Source: freeCodeCamp/freeCodeCamp

Where do I belong

https://www.freecodecamp.com/challenges/where-do-i-belong

Issue Description

I tried passing all the test cases and the output are supposed to be accepted but...

Browser Information

  • Browser Name, Version: Google Chrome, 51.0.2704.79 m (64-bit)
  • Operating System: Windows 7
  • Mobile, Desktop, or Tablet: Desktop

    My Code

function getIndexToIns(arr, num) {
// Find my place in this sorted array.
arr.push(num);
arr.sort(function(a, b){
return a - b;
});
for(var i in arr){
if(arr[i] == num){
return i;
}
}
}

getIndexToIns([2, 20, 10], 19);

untitled

first timers only help wanted

All 6 comments

@wanmi59 the type of the return statement should be an integer, not a string, so that is why the tests are failing. If you get stuck with a challenge, please first ask questions to the Help Room.

However, I do propose rewriting the instructions to be more clear:

Return the lowest index at which a value (second argument) should be inserted into an array (first argument) once it has been sorted. The returned value should be a number.

cc/ @FreeCodeCamp/issue-moderators

@erictleung, sounds good to me!

Those wanting to fix this, this line needs to be changed to:

Return the lowest index at which a value (second argument) should be inserted into an array (first argument) once it has been sorted. The returned value should be a number.

Please first read the contributing guidelines before taking care of this issue. And feel free to visit the Contributors Help chat room if you have any questions about helping. We're there to help.

Can I take this?

@JonW27 go for it!

Was this page helpful?
0 / 5 - 0 ratings