Javascript: Added hint to Check for All or None (#19255)
Added hint to Check for All or None (https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/regular-expressions/check-for-all-or-none and https://guide.freecodecamp.org/certifications/javascript-algorithms-and-data-structures/regular-expressions/check-for-all-or-none/)pull/18629/head^2
parent
5eccd7cd4f
commit
17a7daa4d0
|
@ -1,10 +1,20 @@
|
|||
---
|
||||
title: Check for All or None
|
||||
---
|
||||
|
||||
## Check for All or None
|
||||
|
||||
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/certifications/javascript-algorithms-and-data-structures/regular-expressions/check-for-all-or-none/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
|
||||
|
||||
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
|
||||
|
||||
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
|
||||
|
||||
## The Problem:
|
||||
|
||||
We need to change the regex ```favRegex``` to match both the American English (favorite) and the British English (favourite) version of the word.
|
||||
|
||||
## Solution:
|
||||
|
||||
```js
|
||||
let favWord = "favorite";
|
||||
let favRegex = /favou?rite/; // Change this line
|
||||
let result = favRegex.test(favWord);
|
||||
```
|
||||
|
||||
## Explanation:
|
||||
|
||||
In this regex (```/favou?rite/```), we specify the possible existence of an element (```u```) with a question mark, ```?```.
|
||||
|
|
Loading…
Reference in New Issue