Hi!! So I actually already passed this challenge a few times (I like to review these) and this time I did this solution and somehow it worked. I really want to know how it worked though; why did it only cut the end spaces and not the one in the middle (producing Hello,World!)? I always check my work with console.log and I actually submitted the work so see if it was right and it did indeed pass the tests. Thank you so much!!
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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/18.104.22.168 Safari/537.36
Challenge: Regular Expressions - Remove Whitespace from Start and End
Link to the challenge: