Commutatus interview question

Write a polyfill for Array flat().