const arr = [ { id: 1, text: "123" }, { id: 2, text: "456" }, { id: 3, text: "789" }, ];Por ejemplo, ahora se ve así ^^^, pero necesito que sea algo así:
const arr = [ { id: 1, text: "123," }, { id: 2, text: "456," }, { id: 3, text: "789." }, ];¿Cómo puedo hacerlo?
Aquí tienes:
const arr = [{ id: 1, text: "123" }, { id: 2, text: "456" }, { id: 3, text: "789" }, ] const newArr = arr.map(({ id, text }, idx) => ({ id, text: `${text}${idx < arr.length -1 ? "," : "."}` })) console.log(newArr)