【问题标题】:I encountered a thorny problem about arrays [closed]我遇到了一个关于数组的棘手问题[关闭]
【发布时间】:2022-06-15 16:25:12
【问题描述】:

遇到了一个关于数组的棘手问题,是多级嵌套的问题,这个问题困扰了我好久,那么如何才能得到我想要的结果

      const menu = [
          {
            title: "first",
            second: [
              {
                title: "one",
                children: [{ title: "hello" }, { title: "world" }],
              },
              {
                title: "two",
                children: [{ title: "bad" }],
              },
            ],
          },
          {
            title: "last",
            second: [
              {
                title: "last-one",
                children: [{ title: "good" }, { title: "bye" }],
              },
              {
                title: "last-two",
                children: [{ title: "good" }],
              },
            ],
          },
   
      ];

例如:假设输入“oo”,结果为

menu = [
{
            title: "last",
            second: [
              {
                title: "last-one",
                children: [{ title: "good" }, { title: "bye" }],
              },
              {
                title: "last-two",
                children: [{ title: "good" }],
              },
            ],
          },
]

【问题讨论】:

  • 这可能有助于解释问题究竟是什么,以及你用什么代码来尝试解决它。​​

标签: javascript


猜你喜欢
  • 1970-01-01
  • 2016-06-19
  • 1970-01-01
  • 2011-07-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-05-06
相关资源
最近更新 更多