---
title: "D (@dmtri) | Hashnode"
description: "D personal tech nuggets. Read the latest articles by D on Hashnode."
url: "https://hashnode.com/@dmtri"
---

@dmtri

# D

@dmtri · Joined August 2015

D personal tech nuggets

## Comments

[Here's my solution with maxDepth: function flatten(arr, maxDepth=Infinity, currDepth = 1){ let res = \[\] for (let i = 0; i < arr.length; i++) { if (!Array.isArray(arr\[i\]) || currDepth > maxDepth) { res.push(arr\[i\]) } else { res = res.concat(flatten(arr\[i\], maxDepth, ++currDepth)) } } return res }](https://hashnode.com/posts/javascript-dsa-interview-questions/61141311611d5c199a2fae00/comment/6298d029c9d0c9130286ea55)

Comment · Article · Jun 2, 2022 · [Javascript/Frontend DS&A Interview questions](https://hashnode.com/posts/javascript-dsa-interview-questions/61141311611d5c199a2fae00)
