Created
January 26, 2014 17:29
-
-
Save LESTADru/8636213 to your computer and use it in GitHub Desktop.
функция проверяющая вхождение подстроки в строку, независимо от регистра.
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>функция проверяющая вхождение строки</title> | |
</head> | |
<body> | |
<script> | |
'use strict' | |
function checkSpam(str){ | |
var newStr = str.toUpperCase(); | |
return ( ~newStr.indexOf('VIAGRA') || ~newStr.indexOf('XXX') )? true: false; | |
} | |
alert(checkSpam('buy ViAgRA now')); | |
alert(checkSpam('free xxxxx')); | |
alert(checkSpam("innocent rabbit")); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment