{"action":"opened","issue":{"url":"https://api.github.com/repos/FreeCodeCamp/FreeCodeCamp/issues/11498","repository_url":"https://api.github.com/repos/FreeCodeCamp/FreeCodeCamp","labels_url":"https://api.github.com/repos/FreeCodeCamp/FreeCodeCamp/issues/11498/labels{/name}","comments_url":"https://api.github.com/repos/FreeCodeCamp/FreeCodeCamp/issues/11498/comments","events_url":"https://api.github.com/repos/FreeCodeCamp/FreeCodeCamp/issues/11498/events","html_url":"https://github.com/FreeCodeCamp/FreeCodeCamp/issues/11498","id":186684247,"number":11498,"title":"Which test case is wrong when value equals number in array?","user":{"login":"kerrykimrusso","id":981557,"avatar_url":"https://avatars.githubusercontent.com/u/981557?v=3","gravatar_id":"","url":"https://api.github.com/users/kerrykimrusso","html_url":"https://github.com/kerrykimrusso","followers_url":"https://api.github.com/users/kerrykimrusso/followers","following_url":"https://api.github.com/users/kerrykimrusso/following{/other_user}","gists_url":"https://api.github.com/users/kerrykimrusso/gists{/gist_id}","starred_url":"https://api.github.com/users/kerrykimrusso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kerrykimrusso/subscriptions","organizations_url":"https://api.github.com/users/kerrykimrusso/orgs","repos_url":"https://api.github.com/users/kerrykimrusso/repos","events_url":"https://api.github.com/users/kerrykimrusso/events{/privacy}","received_events_url":"https://api.github.com/users/kerrykimrusso/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-11-02T00:31:38Z","updated_at":"2016-11-02T00:31:38Z","closed_at":null,"body":"Where Do I Belong?\r\nhttps://www.freecodecamp.com/challenges/where-do-i-belong#?solution=%0Afunction%20getIndexToIns(arr%2C%20num)%20%7B%0A%20%20arr.sort()%3B%0A%20%20for(var%20i%20%3D%200%3B%20i%20%3C%20arr.length%3B%20%2B%2Bi)%20%7B%0A%20%20%20%20if(num%20%3C%3D%20arr%5Bi%5D)%20%7B%0A%20%20%20%20%20%20return%20i%3B%0A%20%20%20%20%7D%0A%20%20%7D%0A%20%20%0A%20%20return%20arr.length%3B%0A%7D%0A%0AgetIndexToIns(%5B40%2C%2060%5D%2C%2050)%3B%0A\r\n\r\n\r\n#### Issue Description\r\nTest cases seem contradictory:\r\n> getIndexToIns([10, 20, 30, 40, 50], 30) should return 2.\r\n> getIndexToIns([5, 3, 20, 3], 5) should return 2.\r\n\r\nMy code checks if two numbers are less than or equal:\r\n\r\nif(num <= arr[i]) {\r\n  return i;\r\n}\r\n\r\nand if that's true, I return i. It passes for the first test but not for the second. \r\nThe first test seems to want the index before the number it's equal to, while the second test seems to want the index after the number it's equal to.\r\n\r\n#### Browser Information\r\n* Chrome, Version 53.0.2785.116 (64-bit)\r\n* OSX 10.11.6\r\n* MacBook Air (Mid-2012)\r\n\r\n#### Your Code\r\n```js\r\n function getIndexToIns(arr, num) {\r\n  arr.sort();\r\n  for(var i = 0; i < arr.length; ++i) {\r\n    if(num <= arr[i]) {\r\n      return i;\r\n    }\r\n  }\r\n  \r\n  return arr.length;\r\n}\r\n\r\ngetIndexToIns([40, 60], 50);\r\n```"}}
{"actor":{"display_login":"kerrykimrusso"}}