How to fix the regex so that it checks for the names of Franklin Roosevelt or Eleanor Roosevelt

Tell us what’s happening:

Your code so far

let myString = "Eleanor Roosevelt";
let myRegex = /(Franklin|Eleanor)? Roosevelt/; // Change this line
let result = myString.test(myRegex); // Change this line
// After passing the challenge experiment with myString and see how the grouping works

Your browser information:

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

Challenge: Check For Mixed Grouping of Characters

Link to the challenge:


One suggestion for starters would be to change the last line of code so that it properly tests your regex. Your order is a bit different. It should be:

let result = myRegex.test(myString);

After changing this line, it should pass most of the tests.

The only test it will not past is the “Franklin D. Roosevelt” one. For this one, you need another set of rules like the ones you mention in the first parentheses (Franklin|Eleanor). Try to think of how to write for your regex to search for a space or any other character in between the two names.

Hope it helped at least a bit.
Happy coding.

1 Like