## Notes Implement `Array.flat()`. For example ```javascript const arr = [1, [2], [3, [4]]]; flat(arr) // [1, 2, 3, [4]] flat(arr, 1) // [1, 2, 3, [4]] flat(arr, 2) // [1, 2, 3, 4] ``` This would be a good time to implement the [[MIKE - DSA Interview Strategy]] - [[#Minimally Sketch a Naive Solution]] - [[#Identify Upper and Lower Bounds in Big O Notation]] - Keywords/triggers for optimizing solution - Employ Boosters to find optimizations ## Minimally Sketch a Naive Solution Based on the output of the examples, `flat()` removes the second-level of nesting. `flat()` also operates on the array in-place, which means that the variable in the argument is modified instead of returning an updated copy. One way I could see this working is by operating on the array as if it were a string: convert the array into a string. Once I have the string form, I can match the pairs of brackets to figure out the 2nd level of nesting (if it exists) and remove those brackets. ## Identify Upper and Lower Bounds in Big O Notation The simplest solutions would look like the following - `[]`: an empty array is already flat. The algorithm would need to - `[1]`: an array with one element is already flat - `[...n]`: a 1-dimensional array is already flat ## References Part of [[JavaScript Essentials]]