Genea Interview Question

Flatten array implementation in JS