This code generates a comma separated string to provide a list of ids to the query string of another page, but there is an extra comma at the end of the string. How can I re
Using substring
var strNumber = "3623,3635,";
document.write(strNumber.substring(0, strNumber.length - 1));
Using slice
document.write("3623,3635,".slice(0, -1));
Using map
var strNumber = "3623,3635,";
var arrData = strNumber.split(',');
document.write($.map(arrData, function(value, i) {
return value != "" ? value : null;
}).join(','));
Use Array.join
var strNumber = "3623,3635,";
var arrTemp = strNumber.split(',');
var arrData = [];
$.each(arrTemp, function(key, value) {
//document.writeln(value);
if (value != "")
arrData.push(value);
});
document.write(arrData.join(', '));