how to delete the last Comma from a String in JavaScript

 

How to remove last comma in string using JavaScript?

 

const str1 = '1,2,3,';

const removelastcomma = str1.replace(/,*$/, '');
console.log(removelastcomma);

Tags:

Share:

Related posts