ran npm tdd
This commit is contained in:
4
test/flattenDepth/flattenDepth.js
Normal file
4
test/flattenDepth/flattenDepth.js
Normal file
@ -0,0 +1,4 @@
|
||||
module.exports = flattenDepth = (arr, depth = 1) =>
|
||||
depth != 1
|
||||
? arr.reduce((a, v) => a.concat(Array.isArray(v) ? flattenDepth(v, depth - 1) : v), [])
|
||||
: arr.reduce((a, v) => a.concat(v), []);
|
||||
Reference in New Issue
Block a user