You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f038e671d3f73d5a041973.md
Copy file name to clipboardExpand all lines: curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bc53735149084390e5d0.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,20 +16,20 @@ Using a template literal, in your `if` block, call the `alert()` function to tel
16
16
You should call the `alert()` function in your `if` block.
Copy file name to clipboardExpand all lines: curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,13 +16,13 @@ Still within your `if` block, set `isError` to `true` and return `null`.
16
16
After your `alert`, you should set `isError` to `true`.
Copy file name to clipboardExpand all lines: curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64475c0b61cddb6feaab4e2e.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ Note that `alert()` is a method on the `window` object in the browser, so you ca
18
18
You should call the `alert()` method within the body of your `if` statement within `checkUserInput`.
When there is a falsy value in the `#number-input` element and the `checkUserInput()` function is called, the `alert()` method should display the text `"Please provide a decimal number greater than or equal to 0"`.
Copy file name to clipboardExpand all lines: curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ Add the `return` keyword after `alert()`.
16
16
You should use the `return` keyword after `alert()`.
17
17
18
18
```js
19
-
assert.match(String(checkUserInput),/if\s*\(\s*.+\s*\)\s*\{\s*(window\s*.)?\s*alert\(\s*('|"|`)please provide a decimal number greater than or equal to 0\2\s*\)\s*;?\s*return\s*;?\s*\}/i);
19
+
assert.match(String(checkUserInput),/if\s*\(\s*.+\s*\)\s*\{\s*(window\s*.|globalThis\s*.)?\s*alert\(\s*('|"|`)please provide a decimal number greater than or equal to 0\2\s*\)\s*;?\s*return\s*;?\s*\}/i);
Copy file name to clipboardExpand all lines: curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md
Copy file name to clipboardExpand all lines: curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md
Your `if` statement should display an alert to the user with the message `"Please enter a message."`.
29
29
30
30
```js
31
-
assert.match(code,/checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*(?:messageInput\.value\s*===?\s*('|"|`)\2|('|"|`)\3\s*===?\s*messageInput\.value)\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\4\s*\)/)
31
+
assert.match(code,/checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*(?:messageInput\.value\s*===?\s*('|"|`)\2|('|"|`)\3\s*===?\s*messageInput\.value)\s*\)\s*\{\s*(?:window\.|globalThis\.)?alert\(\s*('|"|`)Please enter a message\.\4\s*\)/)
32
32
```
33
33
34
34
Your `if` statement should exit the function execution.
35
35
36
36
```js
37
-
assert.match(code,/checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*(?:messageInput\.value\s*===?\s*('|"|`)\2|('|"|`)\3\s*===?\s*messageInput\.value)\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\4\s*\)\s*;?\s*return\s*;?\s*\}\s*\}/)
37
+
assert.match(code,/checkMessageButton\.addEventListener\(\s*(['"`])click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*(?:messageInput\.value\s*===?\s*(['"`])\2|(['"`])\3\s*===?\s*messageInput\.value)\s*\)\s*\{\s*(?:window\.|globalThis\.)?alert\(\s*(['"`])Please enter a message\.\4\s*\)\s*;?\s*return\s*;?\s*\}\s*\}/)
Copy file name to clipboardExpand all lines: curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,37 +24,37 @@ Then set the `messageInput` element's `value` property to an empty string.
24
24
You should use the assignment operator to set the `textContent` property of the `result` element.
25
25
26
26
```js
27
-
assert.match(code,/checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*/)
27
+
assert.match(code,/checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*(?:window\.|globalThis\.)?alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*/)
28
28
```
29
29
30
30
You should call the `isSpam()` function after the assignment operator `=` and before the `?` ternary operator.
31
31
32
32
```js
33
-
assert.match(code,/checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(.*\)\s*\?/)
33
+
assert.match(code,/checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*(?:window\.|globalThis\.)?alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(.*\)\s*\?/)
34
34
```
35
35
36
36
You should use ternary syntax to check the truthiness of `isSpam(messageInput.value)`.
37
37
38
38
```js
39
-
assert.match(code,/checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?/)
39
+
assert.match(code,/checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*(?:window\.|globalThis\.)?alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?/)
40
40
```
41
41
42
42
The truthy expression of your ternary should set the `textContent` property of the `result` element to `"Oh no! This looks like a spam message."`.
43
43
44
44
```js
45
-
assert.match(code,/checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:/);
45
+
assert.match(code,/checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*(?:window\.|globalThis\.)?alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:/);
46
46
```
47
47
48
48
The falsy expression of your ternary should set the `textContent` property of the `result` element to `"This message does not seem to contain any spam."`.
49
49
50
50
```js
51
-
assert.match(code,/checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5\s*;?\s*/);
51
+
assert.match(code,/checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*(?:window\.|globalThis\.)?alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5\s*;?\s*/);
52
52
```
53
53
54
54
After your ternary, set the `value` property on the `messageInput` element to an empty string.
55
55
56
56
```js
57
-
assert.match(code,/checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5\s*;?\s*messageInput\.value\s*=\s*('|"|`)\6\s*;?\s*\}/)
57
+
assert.match(code,/checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*(?:window\.|globalThis\.)?alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5\s*;?\s*messageInput\.value\s*=\s*('|"|`)\6\s*;?\s*\}/)
0 commit comments