Using the Test() Method

Tell us what’s happening:
As this challenge description, the test() method will returns true or false if they find or not, respectively.
Look at this code, myRegex has “.” value. But it show me true, where myString variable has no “.” string.
It should be return false. Am I right or not???

Your code so far

let myString = "Hello, World!";
let myRegex = /./;
let result = myRegex.test(myString); // Change this line

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36.

/./ matches everything, instead you can use character classes like /[.]/ to just match that character,


1 Like

. is a special regex character. If you want its literal meaning you can either use

[.] or \.

let myRegex = /\./;
let myRegex = /[.]/;
1 Like