Elegant and readable solution
Code\n\n/**\n * @param {any[]} arr\n * @param {number} depth\n * @return {any[]}\n */\nconst flat = (arr, n) => {\n    if (n === 0) return arr\n\n    const flat
# Code\n```\n/**\n * @param {any[]} arr\n * @param {number} depth\n * @return {any[]}\n */\nconst flat = (arr, n) => {\n    if (n === 0) return arr\n\n    const flatArr = []\n\n    arr.forEach(el => \n        (Array.isArray(el) && n > 0) ? flatArr.push(...flat(el, n - 1)) : flatArr.push(el)\n    )\n\n    return flatArr\n};\n```
['JavaScript']