I have a loop that assembles strings in this format:
var Sabor[0] = "Mussarela, Calabresa, Cebola";
var Sabor[1] = "Mussarela, Presunto, Calabresa, Tomate, Ovos, Pimentão, Cebola";
But I would like to replace the last comma with an "e".
How do I do this?
At first it could be with replace, but there goes the loop code if someone has another idea.
function popularSabores(ClasseDiv, i) {
$(ClasseDiv.toString()).append("<p class='sabor_" + Id + "'>" + Sabor + "</p><p class='ingredientes_" + Id + "'></p>");
$.each(IngredientesArray, function (e, Ingredientes) {
var Ingrediente = Cardapio.Pizza[i].Ingredientes[e].Ingrediente;
if (e > 0) {
IngredientesString += ", ";
}
IngredientesString += Ingrediente;
});
$(".ingredientes_" + Id + "").append(IngredientesString);
}