Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

111
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda