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

163
Views
Problema al entender el método .map en JS

Tengo un controlador de API en el que quiero tomar una serie de entradas de usuario sin formato y convertirlas en datos formateados.

 const _richTextStructure = { text: { content: null}, } ; function stuff2RichText(stuff){ let obj = _richTextStructure; obj.text.content = stuff; arr=[obj]; return arr;} let sample = ["one", "two", "three"]; let newSample = sample.map(txt=>stuff2RichText(txt)) console.log(newSample)

Ahora esperaría que esto devuelva "uno", "dos" y "tres", envueltos en la estructura RT, pero en su lugar me da:

 [[{ text: { content: "three" } }], [{ text: { content: "three" } }], [{ text: { content: "three" } }]]

¿Alguien podría explicar por qué esto no funciona cuando, por ejemplo, sample.map(txt=>txt.toUppercase) devuelve exactamente lo que esperarías?

about 4 years ago · Santiago Trujillo
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!