Regular Expressions: Using the Test Method

Regular Expressions: Using the Test Method
0

#1

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 repl.it 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:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/regular-expressions/using-the-test-method


#2

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


#3

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.


#4

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


#5

@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.


#6

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


#8

This is good:

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