Today I want to share a javascript function that will trim any character from the beginning and the end of the string.
The function will trim all occurrences of the character from the beginning and the end of the string.

function trim_chars(str, char)
{

while (str.substr(0, 1) == char)
str = str.substr(1);

var nrt = str.length;
while (str.substr(nrt-1, 1) == char)
{
str = [...]