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

130
Vistas
build array of json object while looping array of data

I have an array const A=['string1','string2','string3'].

I want to achieve an object that has the following form:

const images = [
  { url: "string1" },
  { url: "string2" },
  { url: "string3" }
];

This is what I've tried:

const images = A.map((image) => {
  JSON.stringify({
    url: `/img/{image}`
  });
});

But the result is an array filled with undefined values.

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

0

I do not understand why are you using JSON.stringify()?

The simplest solution:

const images = A.map((image) => ({
  url: `/img/${image}`
}))

The () that are wrapping the implicit return are mandatory since we're directly returning an object.

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