Flatten Arrays in Vanilla JavaScript with flat() and flatMap()