Skip to content

Instantly share code, notes, and snippets.

@neoswf
Created August 21, 2012 15:32
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 neoswf/3416628 to your computer and use it in GitHub Desktop.
Save neoswf/3416628 to your computer and use it in GitHub Desktop.
Find matches in two arrays
mainList = [-11, -1, 1, 2, 3, 4, 5];
toSearchList = [-1, 1, 4, 6];
document.write('Indexs inside mainList: ');
for (var i = 0; i < mainList.length; i++) {
for (var y = 0; y < toSearchList.length; y++) {
if(mainList[i] == toSearchList[y]){
document.write(i + ', ');
}
}
}​
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment