let quoteSample = "Beware of bugs in the above code; I have only proved it correct, not tried it.";
let vowelRegex = /[aeiou]/gi; // Change this line
let result = vowelRegex.match(quoteSample); // Change this line
In searching for help on this one, I ran across the creator’s thread on FCC which has the solution. Even copying/pasting the solution didn’t work, which only differs from mine in the last line:
His last line: var result = vowelRegex.match(quoteSample).length.
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36.
X You should find all 25 vowels.
X Your regex vowelRegex should use a character class.
X Your regex vowelRegex should use the global flag.
X Your regex vowelRegex should use the case insensitive flag.
X Your regex should not match any consonants.
Thanks, I’m still confused how the creator’s solution is thus:
var quoteSample = "Beware of bugs in the above code; I have only proved it correct, not tried it.";
var myRegex = /[aeiou]/gi; // Change this line
var result = myRegex.match(quoteSample).length; // Change this line
Is he not calling .match() as a method of myRegex? The post is from 2016, so has JavaScript changed since then?
Honestly I doubt (it is changed but not under regexp aspect as far as I know ). Furthermore he is using the length property where it should return an array so…I can’t say. Can I ask you where did you find it?
Not sure if it’s coincidence or not, but this time when I searched Google for the same thing, the link to this forum didn’t show up…
I’m not trying to call anyone out, and I initially made the same mistake which is why I was confused when I found the same syntax in the solution given by the person who wrote the challenge.
Well, that’s what I call a deep search
I see a lot of test condition and other stuff, more related to the background than the challenge itself^^ Probably there something under the hood ( here you can see a match method used to customize the regex MDN - Regex @@Match ), or maybe was just a typo; anyway I think that guy is still here around so we can ask himself directly^^
I do try to Read and Search long before I Ask. I hit a wall with that one, but you pointed me in the right direction.
let ohStr = "Ohhh no";
let ohRegex = /h{3,6}/; // Change this line
let result = ohRegex.test(ohStr);
Actually, this problem is failing, too. It’s finding a match in “Ohhhhhhh no” (with 7 h) and I’m not sure why. It’s like the upper bound isn’t registering, because even if I use /h{3,3}/ it still matches everything after 3.
Yep, that’s because even in this string: “hhhhhhh” you can find this string ( matched by your regex): “hhhhhh”
Just this morning someone had the same doubt, you can search for his topic here around ^^
@javineyatake a look at the code examples in the challenge description and take a look at your code. I guess I designed them so that you can’t just copy paste things, you gotta read your code and realize what you’re doing. The error is in the last light with let result. Hope that helps! And good luck!
Edit: Nevermind, just read through the comments a bit. Mmm I guess I made a mistake when initially writing up the challenge and someone fixed it in production. I’m assuming that when people were QA-ing my challenge, they found that the assumption that an individual would think to use the .length method would be too confusing, so they left it as just the regex itself. That’s be my guess and I hope that helps!
It was my mistake because .test() is a RegEx method and we hadn’t been tasked with typing .match() yet. I just followed the syntax pattern from .test() and it wasn’t working, but @Layer pointed out my error.