Use Capture Groups to Search and Replace

Use Capture Groups to Search and Replace
0.0 0


Tell us what’s happening:
My code’s output is correct but the challenge is not letting me pass. Does anyone have any ideas why I can not pass the challenge? I see there is an alternate way using regEx but why use that way when there is a more practical and efficient way. Do I have to use the regEx way?

Your code so far

let huhText = "This sandwich is good.";
let fixRegex = /good/; // Change this line
let replaceText = "okey-dokey";
let replaceText = huhText.replace(fixRegex, replaceText); // Change this line
let result = huhText.replace(fixRegex, replaceText);

Your browser information:

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

Link to the challenge:


Get rid of this line and everything will be ok :slight_smile:


Hahaha. Thanks man! It’s been a long week. I should have seen the repeat line of code earlier.