Using JavaScript, how can I remove the last comma, but only if the comma is the last character or if there is only white space after the comma? This is my code. I got a wor
Remove last comma. Working example
function truncateText() { var str= document.getElementById('input').value; str = str.replace(/,\s*$/, ""); console.log(str); }
Truncate