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

135
Views
¿Por qué el uso de reducir con concat y el mapa anidado difiere cuando se usa solo el mapa reducido y anidado?

Estoy tratando de entender cómo funciona el siguiente código:

Por cierto, esta es una solución de este problema :

 function getPINs(observed) { return observed.split('') .map( t => ({ '0': [ '0', '8' ], '1': [ '1', '2', '4' ], '2': [ '1', '2', '3', '5' ], '3': [ '2', '3', '6' ], '4': [ '1', '4', '5', '7' ], '5': [ '2', '4', '5', '6', '8' ], '6': [ '3', '5', '6', '9' ], '7': [ '4', '7', '8' ], '8': [ '5', '7', '8', '9', '0' ], '9': [ '6', '8', '9' ] }[t])) .reduce((pre, cur)=> [].concat.apply([], pre.map(t => cur.map(g => t + g)))); }

cuando elimino el método concat del código, el resultado es inesperadamente diferente, como ejemplo, pensé que el resultado sin concat al llamar a getPINs(456) es [['123'],['125'], ...] en su lugar de [123, 125, ...]

about 4 years ago · Juan Pablo Isaza
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!