How to Remove Whitespace from a String in JavaScript
In this lesson, we will see how to remove whitespace from a string in JavaScript, sometimes we want to remove whitespace from a string so how we can do that?
The trim() method
To do that we can use the trim() method that removes the whitespace from the left and the right of the string.
const sayHello = ' Hello World '
console.log(sayHello.trim());
//Hello World