Regular Expressions: Match Single Character with Multiple Possibilities - Answers not matching

Tell us what’s happening:
I was testing to see if i can get the same answer using /a|e|i|o|u/gi instead of /[aeiou]/gi . Why is the result false? The arrays in result1 and result2 appear to be identical.

Your code so far


let quoteSample = "Beware of bugs in the above code; I have only proved it correct, not tried it.";
let vowelRegex1 = /[aeiou]/gi; // Change this line
let vowelRegex2 = /a|e|i|o|u/gi;
let result1 = quoteSample.match(vowelRegex1); // Change this line
let result2 = quoteSample.match(vowelRegex2); // Change this line

console.log(result1===result2)

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0.

Challenge: Match Single Character with Multiple Possibilities

Link to the challenge:

To my knowledge, you cannot compare arrays with the == or === operators. If I convert them to strings, the result changes.

2 Likes

What is aeiou ??? Is it a string an array a boolean???

The [] is an array

That makes sense. Thank you.

aeiou are the letters you need to match in this challenge.

/[aeiou]/ is a regex.

Yes but, did you tell the computer that the where that? U know it because, u read the challenge. Ask yourself how does JS read my text

Altough you are right here. This part of the question was to let OP think about what type of code he was writing.