Add commas between each item outputted in $.each loop, but not at the end of the last

Add commas between each item outputted in $.each loop, but not at the end of the last

Hi all,

I have an .ajax call that appends items and I would like to have each of these comma separated, without having a comma at the end of it. In the example below, it adds commas, but that also means the last value has a comma, which is not how the list of items should end. Any assistance is appreciated.

  1.                 $.each(categoryValueArray, function (index, item) {
                        $.ajax({
                            async: false,
                            url: "https://yourcompany.com/sites/resourcecenter/news/_api/web/lists/GetByTitle('Categories')/items?$filter=ID eq " + item,
                            type: "GET",
                            headers: { "Accept": "application/json;odata=verbose" },
                            success: function (categories) {
                                //script to build UI HERE
                                $.each(categories.d.results, function (index, value) {
                                    $('#BlogPost' + blogPostID).append('<a href="/sites/resourcecenter/news/Lists/Categories/Category.aspx?CategoryId=' + value.ID + '">' + value.Title + '</a>' + ' , ');
                                });









Thanks,

Kelly