ClarkySmiverz77 ClarkySmiverz77 - 3 months ago 9
Javascript Question

Javascript - traversing through object and updating property

I'm hoping someone can point me in the right direction.

I have a JavaScript object like the following ...

Answer
function traverseCategoryTree(categories) {
  for (var i = 0, len = categories.length; i < len; i++) {
    console.log(categories[i]);
    if (categories[i].subcategories) {
      traverseCategoryTree(categories[i].subcategories);
    }
  }
}    

traverseCategoryTree(category);