d4mer
June 22, 2018, 12:54pm
#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
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.
2 Likes
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);
3 Likes