How to loop an array?

Thank you for sharing another approach. Perhaps it is important to point out that there is a different usecase for forEach and map

As I read the docs the map method is useful if you need each result of each iteration as map returns a new array containing the results
of each iteration

The map() method creates a new array with the results of calling a function for every array element.

The map() method calls the provided function once for each element in an array, in order.

In your first example I would use forEach() instead of map() because the result will be unused.

BTW: console.log by itself does nice colorful formatting of arrays and objects by itself.

There is a rundown of many possible debug log options including console.log()