Regular Expressions - Using the Test Method

I believe I have done what the challenge asked
Your code so far

//The lesson says this returns true. It does not.
/*let testStr = "freeCodeCamp";
let testRegex = /Code/;
testRegex.test(testStr);*/

//My answer to this challenge does not either.
/*let myString = "Hello, World!";
let myRegex = /Hello/;
myRegex.test(myString);*/

//I had to copy the solution.
let myString = "Hello, World!";
let myRegex = /Hello/;
let result = myRegex.test(myString);

I am in the Brave Browser ( v1.42.86 ( Aug 3rd, 2022)), I use Windows 11 Pro version 21H2

Device name Tonys2022DellPrecision7760
Processor 11th Gen Intel(R) Core™ i9-11950H @ 2.60GHz 2.61 GHz
Installed RAM 64.0 GB (63.2 GB usable)
Device ID E8F61146-8933-4AEB-82BE-EDB4116034FC
Product ID 00355-60711-00677-AAOEM
System type 64-bit operating system, x64-based processor
Pen and touch No pen or touch input is available for this display
Edition Windows 11 Pro
Version 21H2
Installed on ‎5/‎20/‎2022
OS build 22000.795
Experience Windows Feature Experience Pack 1000.22000.795.0

Challenge: Regular Expressions - Using the Test Method

Link to the challenge:

1 Like

@TonyV good job :clap:t3: . I’m glad you passed the test.

Why doesn’t my commented code work

Both of the tests you described in your comment will return true in the real world,
Can I ask what was the procedure you used for checking them?

Just remember that returning ‘true’ does not mean passing the challenge tests XD

Probably because the test was looking at the value of result, which you deleted. Otherwise test will always return true or false, but you are doing that and tossing that away because its not being assigned to a variable.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.