Possibly wrong description of the problem

Tell us what’s happening:

Description is wrong.
console.log(goRegex) displays only /go*/
But descriptions says it will be ["goooooooo"] , ["g"] , and null .

Your code so far


let soccerWord = "gooooooooal!";
let gPhrase = "gut feeling";
let oPhrase = "over the moon";
let goRegex = /go*/;
soccerWord.match(goRegex);
gPhrase.match(goRegex);
oPhrase.match(goRegex);
console.log(goRegex)

Your browser information:

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

Challenge: Match Characters that Occur Zero or More Times

Link to the challenge:

The description is correct, if a little unclear. goRegex and the matches (soccerWord, etc.) have the values indicated. If you log the matches, instead of just logging the regular expression:

console.log(goRegex);
console.log(soccerWord.match(goRegex));
console.log(gPhrase.match(goRegex));
console.log(oPhrase.match(goRegex));

you’ll get

/go*/
[ 'goooooooo',
  index: 0,
  input: 'gooooooooal!',
  groups: undefined ]
[ 'g', index: 0, input: 'gut feeling', groups: undefined ]
null

as the description states. The rest of the stuff for soccerWord and gPhrase is just the match data that the description didn’t mention.

1 Like

Yeah. Looks like I simply logged the goRegex value of the regular expression. Sorry, my bad.

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