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

202
Views
Remove value from nested array item react native

I have below array format:

[
  {
    "category": "c8kr0cv012vtr8vm3iqg",
    "subcategories": [
      "c8kr3d7012vtr8vm3jm0",
      "c8kr3d7012vtr8vm3jlg",
      "c8kr3d7012vtr8vm3jk0",
      "c8kr8h7012vtr8vm3m5g",
      "c8tjghovq0ahq4ccf980",
      "c8kr3nn012vtr8vm3jog",
      "c8kr3nn012vtr8vm3jo0",
      "c8kr3nn012vtr8vm3jp0",
    ]
  },
  {
    "category": "c8kr0cv012vtr8vm3ivg",
    "subcategories": [
      "c8kr3d7012vtr8vm3jm0",
      "c8kr3d7012vtr8vm3jlg",
      "c8kr3d7012vtr8vm3jk0",
      "c8kr8h7012vtr8vm3m5g",
      "c8tjghovq0ahq4ccf980",
      "c8kr3nn012vtr8vm3jog",
      "c8kr3nn012vtr8vm3jo0",
      "c8kr3nn012vtr8vm3jp0",
    ]
  },
  {
    "category": "c8kr0cv012vtr8vm3is0",
    "subcategories": [
      "c8kr3d7012vtr8vm3jm0",
      "c8kr3d7012vtr8vm3jlg",
      "c8kr3d7012vtr8vm3jk0",
      "c8kr8h7012vtr8vm3m5g",
      "c8kr3nn012vtr8vm3jog",
      "c8kr3nn012vtr8vm3jo0",
      "c8kr3nn012vtr8vm3jp0",
    ]
  },
  {
    "category": "c8kr0cv012vtr8vm3ir0",
    "subcategories": [
      "c8kr3d7012vtr8vm3jm0",
      "c8kr3d7012vtr8vm3jlg",
      "c8kr3d7012vtr8vm3jk0",
      "c8kr8h7012vtr8vm3m5g",
      "c8tjghovq0ahq4ccf980",
      "c8kr3nn012vtr8vm3jog",
      "c8kr3nn012vtr8vm3jo0",
      "c8kr3nn012vtr8vm3jp0",
    ]
  }
]

I want to remove value from subcategory array for example c8tjghovq0ahq4ccf980

I tried below code:

tempPayload.some(function (a) {
  return a.subcategories.some(function (b, i, bb) {
    if (b === "c8tjghovq0ahq4ccf980") {
      bb.splice(i, 1);
      return true;
    }
  });
});

But it is not working any idea how can I resolve this?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Try with following code:

tempPayload.map((item) => {
  const index = item.subcategories.indexOf("c8tjghovq0ahq4ccf980");
  if (index > -1) {
    item.subcategories.splice(index, 1);
  }
});
about 4 years ago · Juan Pablo Isaza Report

0

for(let i=0; i<tempPayload.length; i++){
  tempPayload[i].subcategories = tempPayload[i].subcategories.filter(i => i!==  "c8tjghovq0ahq4ccf980")
}
console.log(tempPayload)
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!