Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@greemwahr
Last active October 29, 2015 01:40
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 greemwahr/c15c73f3f9fe450f9d04 to your computer and use it in GitHub Desktop.
Save greemwahr/c15c73f3f9fe450f9d04 to your computer and use it in GitHub Desktop.
codeSnippet
/* Excellent piece of code to determine the index of a particular
element being searched.*/
var indices = [];
var element = 0;
var idx = arrNum.indexOf(element);
// console.log(idx);
while (idx != -1) {
indices.push(idx);
idx = arrNum.indexOf(element, idx + 1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment