finding information inside of nested arrays

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前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏