Flatten arrays of arbitrary nesting depth into a single linear array using recursion, reduce, and modern flat() methods.
When this program is compiled and executed, the terminal outputs:
Original: [1,[2,[3,4],5],[[6]],7,[8,[9,[10]]]] flattenCustom: [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ] flattenReduce: [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ] Array.flat(Infinity): [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
Practice in our high-performance cloud container IDE with multi-file support, interactive terminal STDIN, real-time memory visualizer, and structured lessons.
Implement a high-performance Least Recently Used (LRU) Cache in JavaScript using the Map structure with O(1) get and put operations.
Validate whether brackets, braces, and parentheses are properly balanced and closed in matching order using a stack.
Learn modern and traditional techniques to reverse a string in JavaScript, including split-reverse-join, recursion, and for...of loops.