Js returns the desired value recursively

  let a = [{
        "k": [{
          "k": [{
            "k": [{
              "name": "4"
            },{
              "name": "5"
            }],
            "name": "2"
          }],
          "name": "1"
        }],
        "name": "0"
      }, 
      {
        "k": [{
          "k": [{
            "k": [{
              "name": "44"
            }],
            "name": "22"
          }],
          "name": "11"
        }],
        "name": "00"
      }]
      
      // 
      ["0-1-2-3-4","0-1-2-3-5", "00-11-22-33-44"]
Mar.21,2021

Brother, you don't have 3 in a, how do you expect to output 3?

function _concat(arr){
    var resulte = [], str = ''
    !function loop(arr,str){
        arr.forEach(item => {
            var s = str + '-' + item.name; 
            Object.prototype.toString.apply(item.k) === "[object Array]" ? loop(item.k,s) : resulte.push(s.replace('-',''))
        })
    }(arr,str)
    return resulte
}
_concat(a)
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e9be35-1892.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e9be35-1892.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?