Tell us what’s happening:
I don’t quite understand the use of the | symbol. It means “or”…but in this imstance aren’t we replacing the whitespace from BOTH sides of the “Hello, World” text? Wouldn’t | indicate replacing one OR the other?
Your code so far
let hello = " Hello, World! ";
let wsRegex = /^\s+|\s+$/g; // Change this line
let result = hello.replace(wsRegex, ""); // Change this line
console.log(result)
Your browser information:
User Agent is: Mozilla/5.0 (X11; CrOS x86_64 13020.87.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.119 Safari/537.36
.
Challenge: Remove Whitespace from Start and End
Link to the challenge: