To remove whitespace from both ends of a string, use the trim()
method.
const str = ' Hello World ';
console.log(str.trim()); // 'Hello World'
Tags: basic, JavaScript, string manipulation
URL: https://www.tiktok.com/@jsmentoring/photo/7455853408113675552