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

141
Views
Conexión de datos de una matriz a un objeto para transformar su valor con un intermediario

¿Cuál sería la mejor manera de usar queued_Dr para alterar sus valores como upcoming_appointments.PCD usando all_appointments ?

¿Cuál sería el mejor enfoque para este problema?

 var queued_Dr = ["Dr.Salazar","Dr.Connors","Dr.Johnson","Dr.Pearson"] upcoming_appointments = [{"DOB":"01-27-2002","name":"Judy, W." ,"PCD":"Dr-S"} ,{"DOB":"08-15-1995","name":"John, V." ,"PCD":"Dr-C"} ,{"DOB":"07-05-1992","name":"David, C.","PCD":"Dr-S"} ,{"DOB":"01-15-2002","name":"Anna, S." ,"PCD":"Dr-J"} ,{"DOB":"01-15-2002","name":"Jeff, D." ,"PCD":"Dr-P"}] all_appointments = [["Dr-S","New York","Dr.Salazar"], ["Dr-C","Austin","Dr.Connors"], ["Dr-J","Austin","Dr.Johnson"], ["Dr-S","New York","Dr.Salazar"], ["Dr-P","San Juan","Dr.Pearson"], ["Dr-J","Austin","Dr.Johnson"]]

Aporte:

 queued_Dr = ["Dr.Salazar","Dr.Connors","Dr.Johnson","Dr.Pearson"]

Salida deseada:

 queued_Dr = ["Dr-S","Dr-C","Dr-J","Dr-P"]

Salida real:

 [ undefined, undefined, undefined, undefined ]

Intentar

 const mapTo = (arrayWithNames) => { var newArray = []; return arrayWithNames.map(name => { const appointment = Object.values(all_appointments) .find(appointment => appointment[2] === name); newArray.push(appointment[0]); }) return newArray; } const result = mapTo(queued_Dr) console.log(result);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

La primera solución es buscar el nombre en all_appointments y devolver la abreviatura correspondiente.

La segunda solución es simplemente componer la abreviatura sin otras matrices.

 const queued_Dr = ["Dr.Salazar","Dr.Connors","Dr.Johnson","Dr.Pearson"]; const all_appointments = [["Dr-S","New York","Dr.Salazar"],["Dr-C","Austin","Dr.Connors"],["Dr-J","Austin","Dr.Johnson"],["Dr-S","New York","Dr.Salazar"],["Dr-P","San Juan","Dr.Pearson"],["Dr-J","Austin","Dr.Johnson"]]; const result1 = queued_Dr .map((queu) => all_appointments .find((appointment) => appointment.at(-1) === queu) .at(0)); console.log(result1); const result2 = queued_Dr .map((queu) => { const [abbr, name] = queu.split('.'); return `${abbr}-${name.at(0)}`; }); console.log(result2);
 .as-console-wrapper {max-height: 100% !important; top: 0}

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!