79percent

Results 2 comments of 79percent

```javascript var arr=[1,2,3,[4,5],[6,[7,[8]]]]; function flatten(arr = []){ const newArr = []; while(arr.length > 0){ const first = arr.shift(); if(Array.isArray(first)){ arr = [...first, ...arr]; }else { newArr.push(first); } } return newArr;...

```javascript function convert(list = []){ const map = new Map(); // 转成Map, id作为key for(const item of list){ const { id } =item; map.set(id, {...item}); } // 遍历Map, 如果有父级,就添加到父级的children中去 for(const [id,...