Skip to content

Instantly share code, notes, and snippets.

@alexandrebvd
Created July 27, 2015 15:51
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 alexandrebvd/4cbfd46481baffb9a6f1 to your computer and use it in GitHub Desktop.
Save alexandrebvd/4cbfd46481baffb9a6f1 to your computer and use it in GitHub Desktop.
18.Bonfire: Where do I belong
function where(arr, num) {
newArr = arr.sort();
finalArr = [];
for (var i = 0; i < newArr.length; i++) {
if (num > newArr[i] && num < newArr[i+1]) {
finalArr.push(newArr[i]);
finalArr.push(num);
} else {
finalArr.push(newArr[i]);
}
}
return finalArr.indexOf(num);
}
@vancovver
Copy link

screen shot 2015-08-04 at 7 09 14 pm

@abhinavmathur
Copy link

1212

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment