0

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.

1 Answer 1

2

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);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.