Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

167
Views
Crear un objeto a partir de dos matrices

Cómo crear un objeto a partir de las siguientes matrices

 var v=[1,2,3,4,5,6] var v1=['A','B','C','D','E'] var result={};

Las claves para el objeto son (nombre y objetivo). Quiero mapear las claves con las dos matrices anteriores como valor como a continuación

 {name: "1", target: "A"} {name: "2", target: "B"} {name: "4", target: "C"}

{nombre: "5", objetivo: "D"} {nombre: "6", objetivo: "E"}

Estaba intentando con la siguiente lógica.

 v.forEach(key=> result[key]= key); console.log('ColResult',result);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Si la primera matriz consiste en números crecientes iguales al índice, entonces no hay necesidad de esa matriz en absoluto...

 result = []; v1.forEach((v, i) => result.push({ name: i, target: v1[i] }));

pero en general debería ser algo como

 result = []; for (var i = 0; i < v.length; i++) { result.push({ name: v[i], target: v1[i] }); }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!