Skip to content
Advertisement

For loop is taking only the last element in the list

I am sorry for a simple question, but tried multiple options without any solution. he Problem I have is the for loop is taking only the last value in the list(Regions).

JavaScript

This is the list and it takes only the last value

JavaScript

It has to take all the values in the list(Regions) and display the result. But it takes only the last value(us-east-1). Please advice what is causing the error.

Advertisement

Answer

Here:

JavaScript

you are creating a new csv file for each region, overwriting the previous one. You want to keep this out of the loop:

JavaScript
Advertisement