Home
Topics
Practice
Roadmap
DSA Tracker
Code Editor
Tech Blogs
More
Sign in
Get started
Loading question...
Feedback
Implement Array.prototype.flat
Medium
00:00
0 users online
Share
Description
Solution
Submissions
Discussion
Write your own array flat implementation.
Sample Input:
[1, [2, 3], [4, [5, 6]]]
Sample Output:
[1, 2, 3, 4, [5, 6]]
Hints
Hint 1
Use recursion for nested arrays
Hint 2
Check the depth parameter
Hint 3
Use Array.isArray() to check for arrays
Code Editor
Reset
Run
Save
Loading...