***Would not let me delete post but I found the issue
I am a little confused as to why my solution does not work for this problem. I am not clear as to why the ending spaces are not being replaced as well.
My code produces : "Hello, World! " (Spaces remain on the end of string).
Any insight would be appreciated!
Your code so far
let hello = " Hello, World! "; let wsRegex = /^(\s*)(.*)(\s*)$/; let result = hello.replace(wsRegex, "$2"); console.log(result);
My test results:
Your browser information:
User Agent is:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.63 Safari/537.36
Challenge: Remove Whitespace from Start and End
Link to the challenge: