en.javascript.info/1-js/4-data-structures/3-string/2-check-spam/solution.md
Ilya Kantor 2b874a73be ok
2016-03-09 00:16:22 +03:00

14 lines
350 B
Markdown

To make the search case-insensitive, let's bring the stirng to lower case and then search:
```js run
function checkSpam(str) {
let lowerStr = str.toLowerCase();
return lowerStr.includes('viagra') || lowerStr.includes('xxx');
}
alert( checkSpam('buy ViAgRA now') );
alert( checkSpam('free xxxxx') );
alert( checkSpam("innocent rabbit") );
```