Solved

accessing array in array items

Posted on 2014-09-03
3
168 Views
Last Modified: 2014-09-03
How can I access an array item in another array?
How can access ["AC1", "AC2"],["BC1", "BC2"], and ["DD1", "DD2"] from the ListOfColumns array below?

Ex:
<script type="text/javascript">
	var ListOfColumns = [["AA", "AB", ["AC1", "AC2"], "AD AE"], ["BB", "BB", ["BC1", "BC2"], "BD BE"], ["CA", "CB", "CC"], ["DD", "DE", ["DD1", "DD2"]]];
	console.log(ListOfColumns);
	console.log("[0]: "+ListOfColumns[0]);
	console.log("[0][0]: "+ListOfColumns[0][0]);
	console.log("[0][1]: "+ListOfColumns[0][1]);
	console.log("[0][2]: "+ListOfColumns[0][2]);
	console.log("[0][3]: "+ListOfColumns[0][3]);
	console.log("[1]: "+ListOfColumns[1]);
	console.log("[1][0]: "+ListOfColumns[1][0]);
	console.log("[1][1]: "+ListOfColumns[1][1]);
	console.log("[1][2]: "+ListOfColumns[1][2]);
	console.log("[1][3]: "+ListOfColumns[1][3]);
	console.log("[2]: "+ListOfColumns[2]);
	console.log("[3]: "+ListOfColumns[3]);
</script>

Open in new window

0
Comment
Question by:Isaac
  • 2
3 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 40301419
Check :

console
0
 
LVL 5

Author Comment

by:Isaac
ID: 40301530
I was able to do that.
I think I explained it wrong.

How do I access just "AC1", "BC1" or "DD1"?
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 40301534
var ac1 = ListOfColumns[0][2][0];
var bc1 = ListOfColumns[1][2][0];
var dd1 = ListOfColumns[3][2][0];
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question