JS Coding Questions Logo
JS Coding Questions
#160💼 Interview💻 Code

How do you search a string for a pattern

Advertisement

728x90

You can use the test() method of regular expression in order to search a string for a pattern, and return true or false depending on the result.

javascript
1var pattern = /you/;
2
3console.log(pattern.test("How are you?")); //true

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 75

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
160of476