Step: Alternation: this or that

Alternation: this or that

The | operator means or — it matches the expression on either side.

Why it matters: alternation lets one pattern accept several distinct options.

Example: cat|dog|bird matches whichever of the three words appears.

Your turn: match all three animals with cat|dog|bird.

Pitfall: | has very low precedence. ^cat|dog$ means "^cat" or "dog$", not "^(cat|dog)$" — wrap alternatives in a group when you need to bound them.

Input:
I have a cat, a dog, and a bird
Expected:
[
  "cat",
  "dog",
  "bird"
]
Step 9 of 11