How to Remove Spaces from a String in JavaScript
In this lesson, we will see how to remove spaces from a string in JavaScript, sometimes we want to remove spaces from a given string so how we can do that?
The replaceAll() method
To do that we can use the replaceAll() method that removes the spaces from the given string.
const sayHello = ' Hello World ';
console.log(sayHello.replaceAll(' ',''));
//HelloWorld