19.12 · Arrays / Practice · 6 min
Choose a row, then an item
Use two positions to read a number, a color and a Boolean.
Activity 12 of 15 in Arrays
JavaScript Basics / 19.12
Choose a row, then an item
Not started
Use two positions to read a number, a color and a Boolean.

Follow two indexes into a nested array
Work through 4 focused steps. Read the explanation, type each requested change and check it before moving on. Your own code carries forward.
The mini-lesson opens in a new tab. Your own code carries forward; each step has a focused check and an optional hint.
Start mini-lesson(opens in a new tab)4 steps · Saved work · Instant feedback
YOUR TURN
Choose a row, then an item
Repair the three bracket accesses without loops. From the provided nestedArray print Number: 30, Color: green, and Flag: true. The first index chooses an inner array; the second chooses an element inside it. Keep the data and output labels; do not replace the accesses with literal answers.
Number: 30 Color: green Flag: true
Keep the starting inputs. Print these lines in this order, without extra output.
Edit JavaScript, then run it. Check Challenge shows which output checks pass or need a fix. Word wrap is enabled.
Ready to checkRun the checks to see your results here.
Your check results
Work in VS Code instead
Copy the starter into a file named practice.js in VS Code. If Node.js is installed, open the terminal in that folder and run node practice.js. Compare the output with the task above. Automated challenge checks are available in the browser editor.
const nestedArray = [
[10, 20, 30],
["red", "green", "blue"],
[true, false, true],
];
console.log("Number: " + nestedArray[0][1]);
console.log("Color: " + nestedArray[1][0]);
console.log("Flag: " + nestedArray[2][1]);Need a nudge?
Read brackets from left to right
nestedArray[0] is the numbers row. Accessing [2] on that row selects its third value. Both levels start at zero.
Each inner array has its own indexes
The colors row is outer index 1; green is its inner index 1. The Boolean row is outer index 2; its first true is inner index 0.
One possible solution
Your code may look different and still be correct. Compare the approach with your own.
A nested array is an array whose elements include other arrays. The first bracket returns a row, which is itself a value you can index. These labels are a visual aid: the outer array is not restricted to equal-length rows or a grid.
const nestedArray = [
[10, 20, 30],
["red", "green", "blue"],
[true, false, true]
];
console.log("Number: " + nestedArray[0][2]);
console.log("Color: " + nestedArray[1][1]);
console.log("Flag: " + nestedArray[2][0]);Ready to try it?
Practice in your browser and see your results.
Progress details
Have a question?
Ask the Code Zone community.
Ask a question in The Code Zone (opens in a new tab)Continue learning

7 days freeTry The Code Zone
THE CODE ZONE COMMUNITY
Your next step is easier together.
Try the community free for 7 days.
No charge during your trial. Choose your plan on Skool.
- Ask questions and get support in the community
- Watch every course video walkthrough
- Find a study buddy in the 24/7 study room
Make the most of your trial with Premium.
Choose Premium on Skool to try Thursday live help sessions. Bring your questions, work through code, and get unstuck together.
Scheduled Thursdays in Eastern Time. Check the Skool calendar for your local date and time.
Have a website account? Sign in