ScanSkill

trim

The trim() method is used to remove white spaces from the given string.

Syntax

string.trim()

Example

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.