Match a Literal String with Different Possibilities1

Match a Literal String with Different Possibilities1
0

#1

Tell us what’s happening:
oh this is hard I can do it

Your code so far


let petString = "James has a pet cat.";
let petRegex = /Emma has a pet rock./; // Change this line
let result = petRegex.test(petString);

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.99 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/regular-expressions/match-a-literal-string-with-different-possibilities


#2

You need to match using the or operation between the strings you wanna match. Like the example it show, if you put/cat|dog/ as regex in the string "You are a cat people?" it match the "cat" and in the string "You are a dog people?" it match the "dog".
Hope it help you.


#3

I write that code:
let petString = “James has a pet cat.”;
let petRegex = /cat|dog/; // Change this line
let result = petRegex.test(petString);

But tell me that:
// running test
Your regex petRegex should return true for the string “Emma has a pet bird.”
Your regex petRegex should return true for the string “Alice has a pet fish.”
// tests completed


#4

from the challenge:

Complete the regex petRegex to match the pets “dog”, “cat”, “bird”, or “fish”.

Do you think your petRegex will match all four of these words?


#5

I believe I will not match all 4 words.


#6

You need to put all words you wanna match in the regex.


#7

Thank you I got it tHank you for helping


#8

You’re welcome.
Happing code!