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

116
Vistas
How to create array of object from tow arrays with extra properties?

I need help to create an array of objects from two exiting array

["A","B","C"]
[1,2,3] 

What I want is something like the below:

[{name: "A", id: 1, trash: false},{name: "B", id: 2, trash: false},{name: "C", id: 3, trash: false}]

properties should be defined as I want it like name and id and the value of them should come from existing arrays.

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

0

Hope this code helping you

const array = ["A","B","C"]
const num = [1,2,3] 
array.map((o,index)=>({name: o,id:num[index],trash:false}))
about 4 years ago · Juan Pablo Isaza Denunciar

0

You can try using Array.prototype.map() that creates a new array populated with the results of calling a provided function on every element in the calling array.

var arr1 = ["A","B","C"]
var arr2 = [1,2,3] 
var resArr = arr1.map((i,idx) => ({name: i, id: arr2[idx], trash: false}));
console.log(resArr);

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