How to Remove last Comma?

Use Array.join

var s = "";
n.each(function() {
    s += $(this).val() + ",";
});

becomes:

var a = [];
n.each(function() {
    a.push($(this).val());
});
var s = a.join(', ');

Leave a Comment