Keep getting result must be equal to Hello, World!

Tell us what’s happening:
Describe your issue in detail here.

Your code so far

let hello = "   Hello,World!  ";
let wsRegex = /^\s(\w+),(\w+)!\s/; // Change this line
let result = hello.replace(wsRegex, 'Hello, World!'); // Change this line

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 5.1.1; SM-J200G) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.110 Mobile Safari/537.36.

Challenge: Remove Whitespace from Start and End

Link to the challenge:


I think you have few typos in your code you have the string hello world together so will be Hello, World!

let hello = "   Hello,World!  ";

This should be right:

let hello = "   Hello, World!  ";

Also i saw your code and you missing on your regexs variable few things:

let wsRegex = /^\s(\w+),(\w+)!\s/; // Change this line

it should be written like this:

let wsRegex = /^\s*\w+,\s\w+!\s*/; // Change this linethis line

Your missing an extra \s and * in your code. Make sure you remove the parentheses.

Thanks a lot it worked.

Awesome glad to help. :slight_smile:

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