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

173
Views
Ejecutando la función de retorno de la función memorizada pero no el resultado

Estoy tratando de adaptar la función memoize al método de utilidad pequeña, sin embargo, estoy haciendo algo mal y agradecería si alguien puede sugerir por qué :)

 const config = { 14340: 1195, 15774: 1226, 17208: 1257, 18642: 1288, 20076: 1319 } const memoize = (fn) => { let cache = {} return (...args) => { let cacheKey = args.map(n => n.toString() + '+').join('') if (cacheKey in cache) { return cache[cacheKey] } else { let result = args.reduce((acc, curr) => fn(acc, curr), 0); cache[cacheKey] = result; return result; } } } function _getMaxValue(config) { const keys = Object.keys(config) .map((k) => parseInt(k, 10)) .sort(); return config[keys[keys.length - 1].toString()]; } const getMaxValue = (config) => memoize(_getMaxValue) const _add = (a, b) => { return a + b } const add = memoize(_add) console.log(getMaxValue(config)) // memoize return block console.log(add(1, 2)) // 3

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!