JavaScript Baazi: How to flatten an array in javaScript?