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/67.0.3396.99 Safari/537.36.
I have tried this but I want fewer lines than this which I was not able to get
let hello = " Hello, World! ";
let wsRegex = /^(\s+)/g;
let result = hello.replace(wsRegex,"");
let wsRegex1 = /(\s+)$/g;
result = result.replace(wsRegex1,"");
console.log(result);