The trim() of a String removes whitespace from both ends of the string and returns a new string without modifying the original string.

    
    const greeting = '   Hello world!   ';

    const greetingTrim = greeting.trim();

    console.log(greetingTrim);
    // "Hello world!";

    console.log(greeting);
    // "   Hello world!   ";