JavaScript’s inbuilt method trim()
removes whitespace from both ends of a string.
The Syntax: str.trim()
The method returns new string representing the str
stripped of whitespace from both ends.
var message = " Hello World ";
console.log(message.trim());
// Output: "Hello World"