Problem with Regular expressions "Using the Test Method"

Tell us what’s happening:

Hi,

This is basic Regexp exercice and my code doesn’t work…I really don’t understand why?

Error message says “result is not defined”

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 (Windows NT 6.1; Win64; x64; rv:52.0) Gecko/20100101 Firefox/52.0.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/regular-expressions/using-the-test-method

you changed the code too much.

if you reset it and apply the expected code change you will get this line:

let result = myRegex.test(myString); // Change this line

I got tripped up too!

Its odd because the example they show us excludes the “let result =”

1 Like

I feel like I run into this a lot on here. Showing an example that doesn’t work or expecting something that isn’t stated is really frustrating.

Some of the things that aren’t stated are considered obvious and so not explicitly stated, like here that you need to assign the result of the test method to a variable

Others you are right

But if you have any trouble the forum is here to help you!