Answers for "trim comma in javascript"


trim comma in javascript

let myString = "string,with,trailing,comma,";

// remove the last character of the string (regardless of what it is)
myString.substr(0, myString.length-1)

// remove only a comma if it appears at the end of the string
myString.replace(/,$/, "");
Posted by: Guest on June-02-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language