Match-characters-that-occur-zero-or-more-times

Match-characters-that-occur-zero-or-more-times
0.0 0

#1

Tell us what’s happening:

I don’t understand what is wrong with my code. when I run the code on my console, it does not match any characters for
“He made a fair move. Screaming about it can’t help you.” and
“Let him have it. It’s not wise to upset a Wookiee.”
yet it does not meet these requirements on the beta free code camp and would not submit to move me to the next level.

Your code so far



let chewieQuote = "Aaaaaaaaaaaaaaaarrrgh!";
let chewieRegex = /a*/i; // Change this line
let result = chewieQuote.match(chewieRegex);
console.log(result);

Your browser information:

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

Link to the challenge:


#2

This is from the challenge you linked:

There’s also an option that matches characters that occur zero or more times.
The character to do this is the asterisk or star: *.

EDIT:

Try this on your browser console:

"He made a fair move. Screaming about it can’t help you.".match(/a*/i);

If there is no match, it should return null.


#3

Hi there - I had the same thing at first but you will need to include two conditions. a* will give you all letters because it includes zero.

let chewieRegex = /aa+a*/ig; /


#4

Why include a+? Shouldn’t /aa*/ig be able to handle it?

Also, I think this is a confusing problem description.

“Create a regex chewieRegex that uses the * character to match all the upper and lower"a” characters in chewieQuote. Your regex does not need flags, and it should not match any of the other quotes."

So there should be one match?

“Your regex should not match any characters in “He made a fair move. Screaming about it can’t help you.””

So it needs to begin with an ‘A’ or an ‘a’?


#5

Nevermind, I see that this is just a bad problem. The trick is to have it catch 2 or more a’s, but it requires a ‘*’ just because that is featured in the problem. In the real world, you would just use /aa+/gi


#6

same here. I think the description of this challenge is kind of confusing as well.