njboot
0
Q:

javascript right trim

function rtrim(str, ch)
{
    for (i = str.length - 1; i >= 0; i--)
    {
        if (ch != str.charAt(i))
        {
            str = str.substring(0, i + 1);
            break;
        }
    } 
    return str;
}
1
//use trim() on your string. It removes first and last whitepsaces

let str = " aa bb    ";
console.log(str.trim()); // "aa bb"
0

New to Communities?

Join the community