Updating the "Reuse Patterns Using Capture Groups" challenge

Tell us what’s happening:

I was stuck in this challenge for a while because of the way the challenge was explained. I feel that by mentioning “\1” maps to “regex” in the example given, it would make more sense.

Your code so far

let repeatStr = "regex regex";
let repeatRegex = /(\w+)\s\1/; // "\1" -> "regex"
repeatRegex.test(repeatStr); // Returns true
repeatStr.match(repeatRegex); // Returns ["regex regex", "regex"]

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/regular-expressions/reuse-patterns-using-capture-groups

It matches what the capture group matches

If you think it needs a clearer explanation you can open an issue on GitHub to discuss it - then if you feel confident you can open a pull request to fix it yourself or someone else will do it eventually

1 Like