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

109
Views
Find by key and replace the value in an object

I'm a bit new with javascript. Is there a way to find all icon and get their value and then replace their values with a new one?

I need to replace all of fa/FaCopy with fcb/FcbCopy in the json payload below. Any libraries or functions you can share?

[
  {
    "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

This will be very customized solution and deeply depended on your data. If your data type will not change and remain same then you could use/modify something like this.

// 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!