---
title: "Discussion on \"Javascript/Frontend DS&A Interview questions\" | Hashnode"
description: "Discussion on \"Javascript/Frontend DS&A Interview questions\". No Frontend interview is complete without DS/Logic question. Interviewers usually look at your problem solving skills in this round. In this series of blogs, we will go through most frequently asked Data Structure and Algorithms questions in Javascri..."
url: "https://hashnode.com/posts/javascript-dsa-interview-questions/61141311611d5c199a2fae00"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Javascript/Frontend DS&A Interview questions](https://devsimplified.hashnode.dev/javascript-dsa-interview-questions?utm_source=hashnode&utm_medium=feed)

No Frontend interview is complete without DS/Logic question. Interviewers usually look at your problem solving skills in this round. In this series of blogs, we will go through most frequently asked Data Structure and Algorithms questions in Javascri...

Aug 11, 2021 · 2 min read · devsimplified.hashnode.dev  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)
-   [#data-structures](https://hashnode.com/tag/data-structures)
-   [#logic](https://hashnode.com/tag/logic)
-   [#technical-interview](https://hashnode.com/tag/technical-interview)
-   [#frontend-development](https://hashnode.com/tag/frontend-development)

## Written by

[Evleensingh Thakral](https://hashnode.com/@evleen13)

@evleen13 · India

  
[View profile](https://hashnode.com/@evleen13)

Software Engineer

## Responses 1

Markdown supported · ⌘↵ to post

[D](https://hashnode.com/@dmtri)

[Jun 2, 2022](https://hashnode.com/posts/javascript-dsa-interview-questions/61141311611d5c199a2fae00/comment/6298d029c9d0c9130286ea55)

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
}
```

[Evleensingh Thakral](https://hashnode.com/@evleen13)

[Nov 15, 2022](https://hashnode.com/posts/javascript-dsa-interview-questions/61141311611d5c199a2fae00/comment/6298d029c9d0c9130286ea55#reply-6373afa5747bca51e27c9a55)

Awesome
