Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattnwa/af2f6a1289989cb4042f to your computer and use it in GitHub Desktop.
Save mattnwa/af2f6a1289989cb4042f 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