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

117
Views
Buscar por clave y reemplazar el valor en un objeto

Soy un poco nuevo con javascript. ¿Hay alguna manera de encontrar todos los icon y obtener su valor y luego reemplazar sus valores por uno nuevo?

Necesito reemplazar todo fa/FaCopy con fcb/FcbCopy en la carga útil json a continuación. ¿Alguna biblioteca o función que puedas compartir?

 [ { "section": "feature-list", "data": { "title": "Title here", "body": "body here", "features": [ { "title": "Title here 1", "image": "body here", "icon": "fa/FaCopy" }, { "title": "Title here 2", "image": "body here", "icon": "fa/FaCopy" }, { "title": "Title here 3", "image": "body here", "icon": "fa/FaCopy" } ] } }, { "section": "title-list", "data": { "title": "Title here", "titles": { "list": [ { "title": "Title here 1", "icon": "fa/FaCopy" }, { "title": "Title here 2", "icon": "fa/FaCopy" }, { "title": "Title here 3", "icon": "fa/FaCopy" } ] } } } ]
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Esta será una solución muy personalizada y dependerá profundamente de sus datos. Si su tipo de datos no cambia y permanece igual, entonces podría usar/modificar algo como esto.

 // DATA = Your array const result = DATA.map((list) => ({ ...list, data: { ...list.data, features: list.data.features?.map((feature) => ({ ...feature, icon: feature.icon === 'fa/FaCopy' ? 'fcb/FcbCopy' : feature.icon })), }, })); console.log(result); // your expected result
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!