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