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