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

208
Views
How to display items like tree/traverse javascript?

I have list of items: "Electronic" It has a category, and that category has a subcategory. How to display it properly like tree/traverse:

Example 
 Example
  Example
  Example
Example 2 
 Example 2 
 Example 2

My Code:

function getData(categories) {  
    categories.forEach((el) => {
      console.log(el);
      let uls = document.createElement('ul')
      let lists = document.createElement('li')
      lists.innerHTML = el.name
      lists.style.listStyle = 'none'
      uls.append(lists)
      boxes.append(uls)
      if(el.hasOwnProperty('categories') && el.categories.length > 0) {
        getData(el.categories, iter)

      }
    })
}
getData(categories)
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!