Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save LESTADru/8636213 to your computer and use it in GitHub Desktop.
Save LESTADru/8636213 to your computer and use it in GitHub Desktop.
функция проверяющая вхождение подстроки в строку, независимо от регистра.
<!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