Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

13 changes: 0 additions & 13 deletions 1-js/05-data-types/03-string/2-check-spam/_js.view/test.js

This file was deleted.

16 changes: 0 additions & 16 deletions 1-js/05-data-types/03-string/2-check-spam/task.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function checkVerb(str) {
let lowerStr = str.toLowerCase();

return lowerStr.includes('move') || lowerStr.includes('swim');
}
13 changes: 13 additions & 0 deletions 1-js/05-data-types/03-string/2-check-verb/_js.view/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
describe("checkVerb", function() {
it('finds verb in "You Should Move"', function() {
assert.isTrue(checkVerb('You Should Move'));
});

it('finds verb in "I am going for a swim"', function() {
assert.isTrue(checkVerb('I am going for a swim'));
});

it('no verb in "innocent rabbit"', function() {
assert.isFalse(checkVerb('innocent rabbit'));
});
});
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
To make the search case-insensitive, let's bring the string to lower case and then search:

```js run demo
function checkSpam(str) {
function checkVerb(str) {
let lowerStr = str.toLowerCase();

return lowerStr.includes('viagra') || lowerStr.includes('xxx');
return lowerStr.includes('move') || lowerStr.includes('swim');
}

alert( checkSpam('buy ViAgRA now') );
alert( checkSpam('free xxxxx') );
alert( checkSpam('You Should Move') );
alert( checkSpam('I am going for a swim') );
alert( checkSpam("innocent rabbit") );
```

15 changes: 15 additions & 0 deletions 1-js/05-data-types/03-string/2-check-verb/task.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
importance: 5

---

# Check for verb

Write a function `checkVerb(str)` that returns `true` if `str` contains 'move' or 'SWIM', otherwise `false`.

The function must be case-insensitive:

```js
checkSpam('You Should Move') == true
checkSpam('I am going for a swim') == true
checkSpam("innocent rabbit") == false
```