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

188
Views
How to find length of object of array of object

json data

I want result like that,

  1. Length: 1
  2. Length: 4
  3. Length: 9 ...etc
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

The original object can be iterated over and the length of each property value can be determined...

const comments ={
"a":[
    {
        "a":"b"
    }],
"b":[
    {
        "a":"b"
    },
    {
        "a":"b"
    },
    {
        "a":"b"
    },
    {
        "a":"b"
    }]    };

let count=1;
for(let key in comments)
{
    console.log(`${count}. Length: ${comments[key].length}`);
    count++;
}
about 4 years ago · Juan Pablo Isaza Report

0

You can use this approach without setting counter. I think the code is explaining itself, but if you need any further explanation i'm here to help.

const keys = Object.keys(comments);

keys.forEach((key, index) => {
    console.log(`${index + 1}. Length: ${comments[key].length}`);
});
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!