Hey framers, in this case how can I call the third string? c[2] doesn't work.
4 Comments
Joshua Tucker
Hey Jiaxin Chen! "C" is a value in the array, starting from index 0 -> array.length and "G" is the index, so by calling "c[2]", you're printing out the value at index [2] for each value in the array, hence why the first two are undefined and the last is "h", which is the third character in "ha>h>", which is at index 2.
You could do a couple of different things:
for c, g in test2 print test[g] if g is 2 print c if g is 2 print test2[2]
Jordan Robert Dobson
c[2] would be undefined, undefined, undefined. You never have any 3rd elements in any objects inside test2
Jordan Robert Dobson
Actually you would get the letter... Never mind Josh mentioned that above.
German Bauer
Do there need to be commas between the first level array elements in test2 ?
4 Comments