The trimEnd() of a String removes whitespace from the end of the string and returns a new string without modifying the original string.

    
    const greeting = '   Hello world!   ';

    const greetingTrimEnd = greeting.trimEnd();

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

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