Regular Expressions: Using the Test Method

Tell us what’s happening:

I am getting the following result when I try to pass the tests:
// running test
result is not defined
// tests completed

I have tried it in and it works as expected and returns true

Your code so far

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

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:61.0) Gecko/20100101 Firefox/61.0.

Link to the challenge:

Looks like the exercise expects the .test() output to be assigned to a result variable.

No, I think the result should be true because the word Hello is in myString.

I am getting the same error. It looks like result is not reading the actual test.

Keep note as to what is not working. The next one does work.

@d4mer You are almost there. You deleted the declaration of the variable result and the assignment operator that was present in the original challenge code. Put those back in and your code will pass all the tests.


Thank you. I followed your advice, reset the challenge and tried again - I passed!

This is good:

let myString = “Hello, World!”;
let myRegex = /Hello/;
let result = myRegex.test(myString);