JS Built-ins
RegExptestbeginner

RegExp test() β€” empty string

πŸ“– Usage Example
const re = /\d+/
re.test('abc123') // β†’ true
re.test('abc')    // β†’ false

Use RegExp.test() to check whether a string matches the regular expression pattern.

RegExp.prototype.test()

/^$/.test('') tests for an empty string.

Challenge: Verify that /^$/.test('') returns true.

πŸ’‘ Hints (1)
  • β€’ /^$/ matches exactly an empty string β€” ^ is start, $ is end