Skip to content

Instantly share code, notes, and snippets.

Created December 7, 2015 15:37
Show Gist options
  • Save anonymous/1963aa85d2595ed0b644 to your computer and use it in GitHub Desktop.
Save anonymous/1963aa85d2595ed0b644 to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/mattnwa 's solution for Bonfire: Where do I belong
// Bonfire: Where do I belong
// Author: @mattnwa
// 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.push(num);
arr.sort(function(a,b){
return a-b;
});
return arr.indexOf(num);
}
where([10, 20, 30, 40, 50], 35);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment