Open jsartisan opened 4 months ago
index.js
export function flatten(arr, depth = 1) { return arr.reduce((acc, value) => { if (Array.isArray(value) && depth > 0) { acc = acc.concat(flatten(value, depth - 1)) } else { acc.push(value) } return acc; }, []) }
index.js