JS remove a vírgula final

str = str.replace(/,\s*$/, "");
Borma