Sense Interview Question

Q: Give me a function that behaves like 'flat' function in JavaScript.