Created
May 14, 2014 11:43
-
-
Save z-------------/53f154bea806f529dedb to your computer and use it in GitHub Desktop.
Check if a string contains at least one element of an array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| String.prototype.containsArrayElement = function(array) { | |
| var returnVal = false; | |
| for(i=0;i<array.length;i++){ | |
| if (this.indexOf(array[i]) != -1){ | |
| returnVal = true; | |
| } | |
| } | |
| return returnVal; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment