Cannot pass result should equal to "Hello, World!"

Tell us what’s happening:
I cannot pass one more test (result should equal to “Hello, World!”)
I tried many ways to solve this problem and read forums related to this challenge. I also tested on regex101 website. Stuck this problem nearly 2 hours by now.

Your code so far

let hello = "   Hello, World!  ";
let wsRegex =  /^\s+|\s+$/g; // Change this line 
let result = wsRegex.test(hello); // 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/78.0.3904.97 Safari/537.36.

Challenge: Remove Whitespace from Start and End

Link to the challenge:

your result is true because you are using .test but the test is looking for a different method to replace and get a string back

1 Like

Yikes. Looks like I forgot to use .replace() method. Thanks for the help.

Not a problem. There were several challenges I was pounding head to keyboard on, only to realize I read the instructions wrong (or a small typo) :slight_smile:

1 Like