Extracting with .match

Tell us what’s happening:
Describe your issue in detail here.
what is the problem with my code here?

Your code so far


let extractStr = "Extract the word 'coding' from this string.";
let codingRegex = extractStr.match(/coding/); // Change this line
let result = codingRegex; // Change this line

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36

Challenge: Extract Matches

Link to the challenge:

It might not be clear, but they don’t want you to do the match on the second line, just change the pattern.

1 Like

but this code would return the correct answer, it is just not in the format that the challenge is asking for, right?

Yes, you are combining two steps into one, so you are technically doing what they want but not how they want you to do it.

Also, with your version, the last line

let result = codingRegex;

is really pointless and unnecessary. If you wanted the result of the match to be in the variable result then you would just do

let result = extractStr.match(/coding/);
1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.