The trim()
method is used to remove white spaces from the given string.
string.trim()
const firstString = ' Scan ';
const secondString = 'Skill ';
let finalString = firstString + secondString;
console.log('-----'+finalString+'-----'); // Prints: ----- Scan Skill -----
finalString = finalString.trim();
console.log('-----'+finalString+'-----'); // Prints: -----Scan Skill-----
The trim()
method removes white spaces from the start, and the end of the string.