Regex Test Fill
Fill in the Blank Medium
Question
Fill in the blank to test if `text` contains at least one digit.
Code
const text = "abc123";
const hasDigit = /\d/.___(text);
console.log(hasDigit);
Hint
Use the regex method that returns true/false.
Explanation
RegExp.test(string) returns true if the string matches the pattern, false otherwise. /\d/.test("abc123") is true because the string contains at least one digit. \d matches any digit character (0-9). The result true is printed.
Related Resources
Related Lessons
- JavaScript Data Types
Learn about regular expressions.
Related Tools
- Regex Tester
Test regular expressions.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.