Flattening sub-arrays in an Array
Given an array with multiple subarray elements, the final function needs to flatten the array to ensure that the array does not contain subarrays.
Sample Code:
function flatArr(arr) {
// Enter your logic here...
}
Examples:
Input: [1,2,3,[4,5],['numbers']]
Output: [1,2,3,4,5,'numbers']
Explanation: The sub-array elements have been flattened.
Input: [1,[2,[3],4],5]
Output: [1,2,3,4,5]
Explanation: The sub-array elements have been flattened.