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

193
Views
I have an array that contains parents and children, how can I count children/grandchildren and whole tree that can be of parent

For example I have an array

[
 {
   login: user1,
   parent: ''
 },
 {
   login: user2,
   parent: user1
 },
 {
   login: user3,
   parent: user1
 },
 {
   login: user4,
   parent: user3
 }
]

I need to count how many children user1 has and set him property childrenAmount. Including that one user4 that is user1's grandchild too and deep of this tree can be different.

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!