Skip to content

Instantly share code, notes, and snippets.

@z-------------
Created May 31, 2014 08:51
Show Gist options
  • Save z-------------/8494d24a86711a4eb828 to your computer and use it in GitHub Desktop.
Save z-------------/8494d24a86711a4eb828 to your computer and use it in GitHub Desktop.
Search a string array for a string and return matching strings (Read the code, it's self-explanatory)
Array.prototype.search = function(string){
var matches = [];
for (i=0; i<this.length; i++) {
if (this[i].indexOf(string) != -1) {
matches.push(this[i]);
}
}
return matches;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment