JS Built-ins
StringString.prototype.matchAllbeginner

String.prototype.matchAll() β€” empty results

πŸ“– Usage Example
const str = 'a1 b2 c3'
const matches = [...str.matchAll(/(w)(d)/g)]
matches.length   // β†’ 3
matches[0][1]    // β†’ 'a'

Use matchAll() with the g flag to iterate over all regex matches and access capture groups in each result.

String.prototype.matchAll() β€” No Matches

When the pattern does not match anything, the spread array is empty.

Challenge: Implement noDigits(str) that returns true when str contains no digit sequences.

noDigits('hello') // β†’ true
noDigits('hi5')   // β†’ false
πŸ’‘ Hints (1)
  • β€’ If the spread array length is 0, there were no matches.