To remove whitespaces inside a string in JavaScript, we call the string replace method.
For instance, we write
const s = "hello world".replace(/\s/g, "");
to call "hello world".replace to replace all spaces with empty strings.
\s matches spaces.
And the g flag makes replace replace all spaces.