JavaScript code to trim a string

Deysomnath
Posted by Deysomnath under JavaScript category on | Views : 1596
function Trim(s)
{
/* Its remove the spaces of the string */
while (s.substring(0,1) == ' ') {
s = s.substring(1,s.length);
}
while (s.substring(s.length-1,s.length) == ' ') {
s = s.substring(0,s.length-1);
}
return s;
}

Comments or Responses

Login to post response