js how to remove the last comma in a string code example Example: remove last comma from string javascript str = str.replace(/,\s*$/, "");