goldEli / Front-End-Training

Front End Training
2 stars 5 forks source link

实现一个 flattenDeep 函数,把嵌套的数组扁平化 #51

Open goldEli opened 4 years ago

goldEli commented 4 years ago
var arr = [1, 2, [3, 4, [5, 6, [7, 8, [9, 10]]]]];

function deepFlatten(arr) {
  // code some staff
}

console.log(deepFlatten(arr)); // [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]