Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save srkama/c3afb57b71b997a1d8a4 to your computer and use it in GitHub Desktop.

Select an option

Save srkama/c3afb57b71b997a1d8a4 to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/srkama 's solution for Bonfire: Where do I belong
// Bonfire: Where do I belong
// Author: @srkama
// Challenge: http://www.freecodecamp.com/challenges/bonfire-where-do-i-belong
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function where(arr, num) {
// Find my place in this sorted array.
arr.sort(function(a,b){return a-b;});
for (i=0;i<=arr.length;i++) {
if (num<=arr[i]) {
return i;
}
}
return i-1;
}
where([40, 60], 50);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment