Oliver Eyton-Williams f1c9b08cf3 fix(curriculum): add isHidden: false to challenges
This includes certificates (where it does nothing), but does not
include any translations.
2020-05-25 16:25:19 +05:30

2.1 KiB

id, title, challengeType, isHidden, forumTopicId
id title challengeType isHidden forumTopicId
587d7db5367417b2b2512b96 Match Letters of the Alphabet 1 false 301354

Description

You saw how you can use character sets to specify a group of characters to match, but that's a lot of typing when you need to match a large range of characters (for example, every letter in the alphabet). Fortunately, there is a built-in feature that makes this short and simple. Inside a character set, you can define a range of characters to match using a hyphen character: -. For example, to match lowercase letters a through e you would use [a-e].
let catStr = "cat";
let batStr = "bat";
let matStr = "mat";
let bgRegex = /[a-e]at/;
catStr.match(bgRegex); // Returns ["cat"]
batStr.match(bgRegex); // Returns ["bat"]
matStr.match(bgRegex); // Returns null

Instructions

Match all the letters in the string quoteSample. Note
Be sure to match both upper- and lowercase letters.

Tests

tests:
  - text: Your regex <code>alphabetRegex</code> should match 35 items.
    testString: assert(result.length == 35);
  - text: Your regex <code>alphabetRegex</code> should use the global flag.
    testString: assert(alphabetRegex.flags.match(/g/).length == 1);
  - text: Your regex <code>alphabetRegex</code> should use the case insensitive flag.
    testString: assert(alphabetRegex.flags.match(/i/).length == 1);

Challenge Seed

let quoteSample = "The quick brown fox jumps over the lazy dog.";
let alphabetRegex = /change/; // Change this line
let result = alphabetRegex; // Change this line

Solution

let quoteSample = "The quick brown fox jumps over the lazy dog.";
let alphabetRegex = /[a-z]/gi; // Change this line
let result = quoteSample.match(alphabetRegex); // Change this line