This file contains 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
// extend strings with the method "contains" | |
String.prototype.contains = function(str) { return this.indexOf(str) != -1; }; | |
// profanities of choice | |
var profanities = new Array("ass", "cunt", "pope"); | |
var containsProfanity = function(text){ | |
var returnVal = false; | |
for (var i = 0; i < profanities.length; i++) { | |
if(text.toLowerCase().contains(profanities[i].toLowerCase())){ | |
returnVal = true; | |
break; | |
} | |
} | |
return returnVal; | |
} | |
var myText = $('#text').html(); | |
if(containsProfanity(myText)){ | |
$('#result').html('That language is profane dude.'); | |
} | |
else{ | |
$('#result').html('That language is just fine.'); | |
} |