Here you go. If you have your array, you can call $.map on it.
$.map(["37", "58", "82"], function(elem) { return { trackID: "track-id-" + elem }; });
Or let's say your string is called your_string...we can act directly on it (I've added whitespace to make it clear what's going on)--
your_string = '37,58,82,';
$.map(your_string.split(','), function(elem)
{
if (elem != '')
{
return { trackID: "track-id-" + elem };
}
});
The if (elem != '') statement is to protect against any empty array values after the split(','). $.map tolerates return values of undefined.
Also consider using $.trim on elem in order to build in tolerance for spaces and so on, e.g.
$.map(your_string.split(','), function(elem)
{
var id = $.trim(elem);
if (id != '')
{
return { trackID: "track-id-" + id };
}
});
37,58,82,intoObject { 0="37", 1="58", 2="82"}?tracks = $.extend({}, tracks);