Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

145
Vistas
Need change an array to add a comma at the end of each 'text', but a dot in the end of last 'text' in object
const arr = [
  { id: 1, text: "123" },
  { id: 2, text: "456" },
  { id: 3, text: "789" },
];

For example now its looks like that ^^^, but need to make it smth like that:

const arr = [
  { id: 1, text: "123," },
  { id: 2, text: "456," },
  { id: 3, text: "789." },
];

How can i do it?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Here you go:

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)

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda