1

I have a newbie question. I want to work with arrays, but I can't reach arrays within an array. Like this :

function myFunction() { 

    var id1 = 1
    var id2= "test"
    var X = [5]
    var id = [[id1, X], [id2]]

    Logger.log(id[0]);
    Logger.log(id[0,1]);
}

How do I only get the X here inside the array? I assumed the second logger would return the [5] - but no, it returns "test".

1 Answer 1

3

You can reference variables with multiple indexes one after another, like so (using your Logger syntax):

Logger.log(id[0][1]);
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.