From bfe76794c069c492202512d29b09e3b134a5d943 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damjan=20Ostreli=C4=8D?= Date: Tue, 19 May 2020 04:50:50 +0100 Subject: [PATCH] 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> --- .../regular-expressions/check-for-all-or-none.english.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/check-for-all-or-none.english.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/check-for-all-or-none.english.md index 6b726bbaef..100473323e 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/check-for-all-or-none.english.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/check-for-all-or-none.english.md @@ -32,13 +32,13 @@ Change the regex favRegex to match both the American English (favor ```yml tests: - text: Your regex should use the optional symbol, ?. - testString: assert(favRegex.source.match(/\?/).length > 0); + testString: favRegex.lastIndex = 0; assert(favRegex.source.match(/\?/).length > 0); - text: Your regex should match "favorite" - testString: assert(favRegex.test("favorite")); + testString: favRegex.lastIndex = 0; assert(favRegex.test("favorite")); - text: Your regex should match "favourite" - testString: assert(favRegex.test("favourite")); + testString: favRegex.lastIndex = 0; assert(favRegex.test("favourite")); - text: Your regex should not match "fav" - testString: assert(!favRegex.test("fav")); + testString: favRegex.lastIndex = 0; assert(!favRegex.test("fav")); ```