Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

ashley einspahr
1,226 PointsCan you have multiple arrays? If so, I'm confused how you can create a new variable that knows which array to pull from?
Can you have multiple arrays? If so, I'm confused how you can create a new variable that knows which array to pull from?
Specifically referring to when we added this line: var index = 0
Thanks!
2 Answers

Donald Test
3,339 PointsYes, you can have multiple arrays. Since each array should have a different name, each will be referenced separately. Also, "index" in the case you're talking about is arbitrary. You could write i or whatever you like. As long as you initialize the variable and use different variables for each array (when incrementing for the loop, that is), you should be fine.

Donald Test
3,339 PointsYep, that's exactly it. For your other array it would be beneficial to use a different variable or constant (depending on what you require). Of course, depending on the purpose, you could use the same variable to reference different arrays. It all comes down to what functions you want to the code to complete.

ashley einspahr
1,226 PointsAwesome. Thanks!

Donald Test
3,339 PointsYou're welcome!
ashley einspahr
1,226 Pointsashley einspahr
1,226 PointsI think that makes sense. So if I had 2 arrays, and then created a variable to reference the first array only, how would that look? Would it be something like var index = array1[0]?