Asynchronous loops in Javascript - using forEach, map, and for loop