* feat(tools): add seed/solution restore script * chore(curriculum): remove empty sections' markers * chore(curriculum): add seed + solution to Chinese * chore: remove old formatter * fix: update getChallenges parse translated challenges separately, without reference to the source * chore(curriculum): add dashedName to English * chore(curriculum): add dashedName to Chinese * refactor: remove unused challenge property 'name' * fix: relax dashedName requirement * fix: stray tag Remove stray `pre` tag from challenge file. Signed-off-by: nhcarrigan <nhcarrigan@gmail.com> Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
1.7 KiB
id, title, challengeType, forumTopicId, dashedName
id | title | challengeType | forumTopicId | dashedName |
---|---|---|---|---|
587d7dba367417b2b2512ba8 | Check for All or None | 1 | 301338 | check-for-all-or-none |
--description--
Sometimes the patterns you want to search for may have parts of it that may or may not exist. However, it may be important to check for them nonetheless.
You can specify the possible existence of an element with a question mark, ?
. This checks for zero or one of the preceding element. You can think of this symbol as saying the previous element is optional.
For example, there are slight differences in American and British English and you can use the question mark to match both spellings.
let american = "color";
let british = "colour";
let rainbowRegex= /colou?r/;
rainbowRegex.test(american); // Returns true
rainbowRegex.test(british); // Returns true
--instructions--
Change the regex favRegex
to match both the American English (favorite) and the British English (favourite) version of the word.
--hints--
Your regex should use the optional symbol, ?
.
favRegex.lastIndex = 0;
assert(favRegex.source.match(/\?/).length > 0);
Your regex should match "favorite"
favRegex.lastIndex = 0;
assert(favRegex.test('favorite'));
Your regex should match "favourite"
favRegex.lastIndex = 0;
assert(favRegex.test('favourite'));
Your regex should not match "fav"
favRegex.lastIndex = 0;
assert(!favRegex.test('fav'));
--seed--
--seed-contents--
let favWord = "favorite";
let favRegex = /change/; // Change this line
let result = favRegex.test(favWord);
--solutions--
let favWord = "favorite";
let favRegex = /favou?r/;
let result = favRegex.test(favWord);