Skip to content

Instantly share code, notes, and snippets.

Created December 10, 2015 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/5305830b7eb03ed7fc83 to your computer and use it in GitHub Desktop.
Save anonymous/5305830b7eb03ed7fc83 to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/duggiemitchell 's solution for Bonfire: Where do I belong
// Bonfire: Where do I belong
// Author: @duggiemitchell
// 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) {
arr.push(num);
arr.sort();
var newArr = arr.sort(function(a,b) {
return a - b;
});
return newArr.indexOf(num);
}
where([2, 20, 10], 19);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment