I know my solution will only work if the whitespace before and after the text is >= 2 but it came through. Maybe you should add more test strings so it can`t be this solution.
let hello = " Hello, World! ";
let wsRegex = /(\s+){2,}/g; // Change this line
let result = hello.replace(wsRegex,""); // Change this line
console.log(result);