Array Coding Interview Question - Flatten an Array in JavaScript