The only thing about this solution that is confusing me is the use of the | “or” operator . I thought that the or operator would only take one or the other. So I assumed that in this particular lesson that it would only take the first set of white space or the second set of white space.
So, Regardless of the | or operator does it take both sets of white space because regular expressions are greedy?
Your code so far
let hello = " Hello, World! "; let wsRegex = /^\s+|\s+$/g; // Change this line let result = hello.replace(wsRegex, ''); // 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/84.0.4147.89 Safari/537.36.
Challenge: Remove Whitespace from Start and End
Link to the challenge: