each loop remove comma end of the string jquery code example Example: remove last comma from string javascript str = str.replace(/,\s*$/, "");