String.prototype.matchbeginner'test 123 foo'.match(/d+/) // β ['123', index: 5, ...]
'test 1 and 2'.match(/d+/g) // β ['1', '2']Use match() to search a string against a regex and return the match results, or null if not found.
When the regex does not match, .match() returns null.
Challenge: Implement hasMatch(str, pattern) that returns true when the pattern is found.
hasMatch('hello123', /\d+/) // β true
hasMatch('hello', /\d+/) // β false