Use splice to remove the specified items in the array, the result is incorrect

use splice to remove the items specified in the array, but the result is not correct
the following code, I need to keep children.path=allOrder | | items of children.path=accessPage

    let routers = [
        {
            path: "/index",
            name: "Index",
            children: [{
                path: "accountManagement",
                name: "accountManagement",
                meta: { title: "", icon: "el-icon-setting" }
            }]
        },
        {
            path: "/index",
            name: "paltform logs",
            meta: { title: "", icon: "el-icon-menu" },
            children: [{
                    path: "UserBehavior",
                    meta: { title: "" },
                    name: "UserBehavior"
                }, {
                    path: "errorOrder",
                    meta: { title: "" },
                    name: "errorOrder"
                }, {
                    path: "statisticRecharge",
                    meta: { title: "" },
                    name: "StatisticRecharge"
                },
                {
                    path: "allOrder",
                    meta: { title: "" },
                    name: "allOrder"
                }, {
                    path: "userRechargeError",
                    meta: { title: "" },
                    name: "userRechargeError"
                }
            ]
        },
        {
            path: "/index",
            name: "wechat api",
            meta: { title: "", icon: "el-icon-menu" },
            children: [{
                path: "chart",
                meta: { title: "" },
                name: "Chart"
            }, {
                path: "visitDistribution",
                meta: { title: "" },
                name: "VisitDistribution"
            }, {
                path: "accessRetention",
                meta: { title: "" },
                name: "AccessRetention"
            }, {
                path: "accessPage",
                meta: { title: "" },
                name: "accessPage"
            }, {
                path: "userPortrait",
                meta: { title: "" },
                name: "UserPortrait"
            }, {
                path: "payStatistics",
                meta: { title: "" },
                name: "PayStatistics"
            }]
        }
    ]

 
    function filterAsyncRouter(Router) {
        console.log(Router)
      if(Router && Router.length){
        for(let i=0;i<Router.length;iPP){
            if(Router[i].name && Router[i].children){
              for(let k=0;k<Router[i].children.length;kPP){
                  if(!hasPermissionName(Router[i].children[k].name)){
                    Router[i].children.splice(k,1)
                    kPP
                  }
              }
            }
          
        }
      }
      console.log(Router)
    }

   function hasPermissionName(routerName) {
       let permissions = ["allOrder","accessPage"]
      for (let i = 0; i < permissions.length; iPP) {
        if(permissions[i]===routerName){
          return true
        }
      }
    }

    filterAsyncRouter(routers)

Mar.30,2021

change kPP to KMY-

Menu