Hello!
I’ve found solution for Regular Expressions - Remove Whitespace from Start and End Challenge which I think is a little simpler than what is present as Solution in Guide Page.
I’ve checked it with multiple words, devided by multiple whitespaces and I think it works as it should. Am i right or am I missing something? Does .replace() has any kind of adventage in that case?
FreeCodeCamp proposed solution:
let hello = " Hello, World! ";
let wsRegex = /^\s+|\s+$/g; // Change this line
let result = hello.replace(wsRegex, ""); // Change this line
My solution:
let hello = " Hello, World! ";
let wsRegex = /\S+.*\S+/; // Change this line
let result = hello.match(wsRegex)[0]; // Change this line
Thank you in advance for you comments!