so I have finished the challenge, I looked at the solution to check how it was done, and I have a question.
let hello = " Hello, World! ";
let wsRegex = /^\s+|\s+$/g; // Change this line
let result = hello.replace(wsRegex, ""); // Change this line
I understand the regex, but the result where it removes all empty strings didn’t it remove the one at Hello, World as well? the one after the comma.
Thanks!
Your code so far
let hello = " Hello, World! ";
let wsRegex = /^(\s+)Hello,\sWorld!(\s+)$/; // Change this line
let result = hello.replace(wsRegex, "Hello, World!"); // 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
Challenge: Remove Whitespace from Start and End
Link to the challenge: