Hello, quick question:
I see in the SugarCube documentation that .first() returns the first member of the array; so how do you get the second member? Maybe a simple question, but google search is turning up nothing.
Thanks!
Hello, quick question:
I see in the SugarCube documentation that .first() returns the first member of the array; so how do you get the second member? Maybe a simple question, but google search is turning up nothing.
Thanks!
Ah, is it <Array>
[number]? As in: $pies[2]? I found something else that used an array and something like this was in it, and it seems to work.
To access any element of an array you just do $arrayName[index]
, where “index
” is a number from 0
to $arrayName.length - 1
.
So, to access the second element you’d use $arrayName[1]
, because the first element is at $arrayName[0]
.
For more information see the MDN Array documentation.