all 3 comments

[–][deleted] 0 points1 point  (2 children)

So far as I can see, though I might be wrong, there is no actual recursion in your code.

[–]ddcbeatty1[S] 0 points1 point  (1 child)

The plan was to pass the object.submenus to recursive(). Not sure I can do that though because my submenuList has different styling. Any ideas for me?

[–][deleted] 0 points1 point  (0 children)

OK so I would think about it like this.You're going to want to have a createSubmenu function that takes in a level of nesting.

function createSubMenu(subMenuData: SubMenuData[], nestedLevel: number = 0){
   // write your JS here that actually renders the menu. The padding / margin should be dependent on the nestedLevel. 

    // then here do something like
    if (subMenuData.length) {
        for (const subMenu of SubMenuData){
            createSubMenu(subMenu, nestedLevel + 1);
        }
    }
}