I have an array that stores the values:
var array = [['favorite color'],['black','red']]
to get `black` I would:
document.write(array[0][1][0]);
then if i append to the array another question `[['favorite thing']['box','ball']]`
If I wanted ball I would:
document.write.array[1][1][1];
I am having trouble understanding arrays. I want an array with one question and multiple answers then I want to loop through them and display everything. I can do the loop but I am unsure how to find things in nested arrays once I create them. "to get black I would: ... array[0][1][0]. No, that would result in an error. This would imply a structure such as [[...,['black',...]], ...]. You would get black with array[1][0] because array has to two elements, both arrays, and you want to get the first element (0) of the second array (1).
以上就是finding information inside of nested arrays的详细内容,更多请关注web前端其它相关文章!