function rtrim(str, c, invert) {
            if (str.length === 0) {
                return '';
            }

            // Length of suffix matching the invert condition.
            var suffLen = 0;

            // Step left until we fail to match the invert condition.
            while (suffLen < str.length) {
                var currChar = str.charAt(str.length - suffLen - 1);
                if (currChar === c && !invert) {
                    suffLen++;
                } else if (currChar !== c && invert) {
                    suffLen++;
                } else {
                    break;
                }
            }

            return str.substr(0, str.length - suffLen);
        }
// invert: Remove suffix of non-c chars instead. Default falsey.
Remove suffix of non-c chars instead. Default falsey.
Remove suffix of non - c chars instead . Default falsey .
function rtrim(str, c, invert) {
            if (str.length === 0) {
                return '';
            }
            var suffLen = 0;
            while (suffLen < str.length) {
                var currChar = str.charAt(str.length - suffLen - 1);
                if (currChar === c && !invert) {
                    suffLen++;
                } else if (currChar !== c && invert) {
                    suffLen++;
                } else {
                    break;
                }
            }
            return str.substr(0, str.length - suffLen);
        }
function rtrim ( str , c , invert ) { if ( str . length === 0 ) { return '' ; } var suffLen = 0 ; while ( suffLen < str . length ) { var currChar = str . charAt ( str . length - suffLen - 1 ) ; if ( currChar === c && ! invert ) { suffLen ++ ; } else if ( currChar !== c && invert ) { suffLen ++ ; } else { break ; } } return str . substr ( 0 , str . length - suffLen ) ; }
invert: Remove suffix of non-c chars instead.
invert : Remove suffix of non - c chars instead .
// Length of suffix matching the invert condition. // Step left until we fail to match the invert condition.