Reputation: 303
Is there a possibility to use the contents of an array in another function? For example, I have the following code:
var locations = [];
function values() {
var values = ['test1','test1']
for (i in values) {
locations.push(values[i]);
}
}
Logger.log(locations)
Now it logs nothing, but if I place the logger in the function, it returns the contents of the array.
Upvotes: 0
Views: 55
Reputation: 394
call function values(); like this
var locations = [];
values();
function values() {
var values = ['test1','test1'];
for (i in values) {
locations.push(values[i]);
}
}
Logger.log(locations);
Upvotes: 2