It was easy to solve, on my Visual Studio anyway, but the problem is freeCodeCamp’s compiler would not accept anything other that the result shown in the Help Solution.
My code had 2 different answers and both worked in Visual Studio. Am I missing something? This doesn’t make sense to me.
Your code so far
let myString = "Hello, World!";
let myRegex = /Hello/;
// My first answer:
myRegex.test(myString);
// My second answer:
let answer = myRegex.test(myString);
// Both were rejected. The only answer acceptable was:
let result = myRegex.test(myString);
let myString = "Hello, World!";
let myRegex = /Hello/;
let result = myRegex; // Change this line
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36 Edg/97.0.1072.62
Challenge: Using the Test Method
Link to the challenge: