输入:
const arrs = [
{
name: '广东',
children: [
{
name: '深圳',
children: [
{
name: '南山区',
children: []
}
]
},
{
name: '广州',
children: [
{
name: '白云区',
children: []
}
]
}
]
},
{
name: '上海',
children: [
{
name: '浦东新区',
children: []
}
]
},
{
name: '北京',
children: [
{
name: '朝阳区',
children: []
}
]
}
]
输出:
[
{
name: '广东',
children: [
{
name: '深圳',
children: []
},
{
name: '广州',
children: []
}
]
},
{
name: '上海',
children: []
},
{
name: '北京',
children: []
}
]
如上所示,删除了区的那一层,保留到市。
function removeLevel(arrs) {
// todo
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…