Tell us what’s happening:
For some reason this code fails the test “result
should be equal to the string Hello, World!
”. Passing result
into console.log
gives me Hello, World!
as expected, and typeof result
even gives me a string. What am I doing wrong here?
Your code so far
let hello = " Hello, World! ";
let wsRegex = /^(\s+)(.+)(\s+)$/; // Change this line
let result = hello.replace(wsRegex, '$2'); // Change this line
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0
Challenge: Regular Expressions - Remove Whitespace from Start and End
Link to the challenge: