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

132
Views
Javascript filter object by condition on only one of its keys

I have an object with the following structure:

data = 
{
  columns: array of objects,
  rows: [
    {
      id: 1,
      process: "A",
      status: "ok"
    },
    {
      id: 2,
      process: "A",
      status: "ko"
    },
    {
      id: 3,
      process: "B",
      status: "ok"
    },
    ...
  ]
}

I then want to create another object that has the same column values, but in the rows field I want to put only the objects that have process === "A".

I've come up with this so far, that I think it's fine:

const filteredData = {
    "columns": data.columns,
    "rows": selectedProcess !== '' ? data.rows.filter(r => r.process === selectedProcess) : []
  }

My question is if there is another way to make this in a more clever way.

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

0

You can check out the solution Below:

const filteredData = {
    "columns": data.columns,
    "rows": data.rows.filter(item=>item.process==='A')
  }

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!