How can I determine the number of times two distinct patterns occur in a given string? Specifically, I need to identify instances of fly
or flies
. While I have managed to find occurrences of one pattern, I'm unsure how to search for both.
Here's what I've attempted:
const flyCount = str => {
return (str.match(/fly/g) || str.match(/flies/g) || []).length;
}