To remove the white spaces between the characters from a string we need to use the
Here is an example:
const string = "hello have some fun"; const remove = string.replace(/\s/g,""); console.log(remove); // hellohavesomefun
In the above code, we have passed the regex
\sis the regex for whitespace.
- g is the global flag, meaning match all