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

140
Views
React JS Filter a 2D array for empty cells

Can you help me translate my method to an arrow function? Learning that atm, but this is a bit to complex for me already.

The state:

const [data, setData] = useState([]);

The array look something like that:

[
  [
    value: "---",
    value: "ColumnHeader1",
    value: "ColumnHeader2",
    value: "ColumnHeader3"
  ],
  [
    value: "RowHeader1",
    value: "Value11",
    value: "Value12",
    value: "Value13"
  ],
  [
    value: "RowHeader2",
    value: "Value21",
    value: "Value22",
    value: "Value23"
  ],
]

My method which is already working:

  function removeEmptyCells() {
    setData(prevState => {

        let array = [];

        for (let i = 0; i < prevState.length; i++) {
            console.log(prevState[i])

            let innerArray = []

            for (let x = 0; x < prevState[i].length; x++) {
                if (Object.keys(prevState[i][x]).length !== 0) {
                    innerArray.push(prevState[i][x])
                }
            }
            if (innerArray.length > 0) {
                array.push(innerArray);
            }

        }

        return array;
    })
}

Can you help me to translate this method to an arrow function?

about 4 years ago · Juan Pablo Isaza
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!