Allow use of g flag in Regular Expressions: Check for All or None (#38659)

* allow use of g flag

added functionality of tests to allow for the use of g flag by resetting the lastIndex as per example in https://github.com/freeCodeCamp/freeCodeCamp/pull/37941.

* Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/check-for-all-or-none.english.md

Co-Authored-By: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>

* Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/check-for-all-or-none.english.md

Co-Authored-By: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>

* Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/check-for-all-or-none.english.md

Co-Authored-By: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>

* Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/check-for-all-or-none.english.md

Co-Authored-By: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>

Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
This commit is contained in:
Damjan Ostrelič
2020-05-19 04:50:50 +01:00
committed by GitHub
parent 7e2b159350
commit bfe76794c0

View File

@ -32,13 +32,13 @@ Change the regex <code>favRegex</code> to match both the American English (favor
```yml
tests:
- text: Your regex should use the optional symbol, <code>?</code>.
testString: assert(favRegex.source.match(/\?/).length > 0);
testString: favRegex.lastIndex = 0; assert(favRegex.source.match(/\?/).length > 0);
- text: Your regex should match <code>"favorite"</code>
testString: assert(favRegex.test("favorite"));
testString: favRegex.lastIndex = 0; assert(favRegex.test("favorite"));
- text: Your regex should match <code>"favourite"</code>
testString: assert(favRegex.test("favourite"));
testString: favRegex.lastIndex = 0; assert(favRegex.test("favourite"));
- text: Your regex should not match <code>"fav"</code>
testString: assert(!favRegex.test("fav"));
testString: favRegex.lastIndex = 0; assert(!favRegex.test("fav"));
```