Right trim an array with for loop - Node.js String

Node.js examples for String:Trim

Description

Right trim an array with for loop

Demo Code

String.prototype.rTrim = function(){
  str = this;/*from w w w . ja v a2  s  .com*/
  var i;
    for(i=str.length-1;i>=0;i--)
    {
        if(str.charAt(i)!=" "&&str.charAt(i)!=" ")break;
    }
    str=str.substring(0,i+1);
    return str;
}

Related Tutorials