Reuse Patterns Using Capture Groups 4246

Tell us what’s happening:

why is this not working?

Your code so far


let repeatNum = "42 42 42";
let reRegex = /(\d+)\s\1\s\1$/; // Change this line
let result = reRegex.test(repeatNum);

Your browser information:

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

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

you are using only the anchor for end of word, your regex can still test true for 42 42 42 42 - can you figure out what you need to fix this?

Your regex is correct. It will start with a number and has to end with a number. It will fail in this test case 42 42 42 42. Because according to the regex you wrote it will match the pattern. It will find 42 42 42. So inorder to change this. Make sure to add the ^ caret character at the beginning.