Tell us what’s happening:
I do not understand why the sign | is used as part of the solution. Doesn’t | mean OR? Wouldn’t that result in only either the front portion or the end portion to be selected instead of both? Please help to clarify it for me. Thank you.
Furthermore, would my solution be considered passable?
Your code so far
let hello = " Hello, World! ";
let wsRegex = /\s+(\S+)\s(\S+)\s+/; // Change this line
let result = hello.replace(wsRegex,"\1\s\2"); // Change this line
console.log(result)
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36
.
Challenge: Remove Whitespace from Start and End
Link to the challenge: