Tell us what’s happening:
For some reason my code isn’t working
Your code so far
let quoteSample = “Beware of bugs in the above code; I have only proved it correct, not tried it.”;
let vowelRegex = /b[aeiou]g/gi; // Change this line
let result = quoteSample.match(vowelRegex); // Change this line
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36
.
Challenge: Match Single Character with Multiple Possibilities
Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/regular-expressions/match-single-character-with-multiple-possibilities
You are supposed to be matching just vowels. You are only matching instances where a b
or B
exists immediately before a single vowel, followed by the letter g
or G
. That is not what the challenge instructions want. What is the purpose of adding the b
and the g
?
I thought you needed it to complete a word
Where in the instructions does it tell you to match words that start with b
followed by a vowel and then followed by g
?
Your RegExp is only looking for the matches to “bag”, “beg”, “big”, “bog”, and “bug”. Remove the “b” and “g”, i.e. /[aeiou]/gi
. You’re only matching “bug”.
If you can’t figure out how to solve something like this, simply end your code with console.log
to debug it (no pun intended
).
it doesn’t I got rid of it
It logs 25 when I console.log it but won’t run in the code I have before
What does you latest code look like?