Skip to content

Instantly share code, notes, and snippets.

@erming
Last active August 29, 2015 14:00
Show Gist options
  • Save erming/11317321 to your computer and use it in GitHub Desktop.
Save erming/11317321 to your computer and use it in GitHub Desktop.
String.contains.js
//
// Check if string contains any of the supplied words.
//
// Usage:
// "".contains(a, b, ...);
//
// Returns [true|false]
//
String.prototype.contains = function() {
var args = arguments;
for (var i in args) {
var str = args[i];
if (typeof str === "string" && this.indexOf(str) > -1) {
return true;
}
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment