Lesson 2 of 40
Lesson Progress: 0%
Code Example
const fruits = ["apple", "banana", "orange"];
console.log(fruits);
// ["apple", "banana", "orange"]Instructions
▼ ← Click the triangle to hide or reveal instructions.JavaScript Code Editor
Task Incomplete
Editor Input:
Editor Output:
[ ] to act like the walls of the box that keep your list together.Code Example
const colors = ["red", "green", "blue"];
console.log(colors[0]);
// redInstructions
▼ ← Click the triangle to hide or reveal instructions.JavaScript Code Editor
Task Incomplete
Editor Input:
Editor Output:
0 instead of 1!colors box is found at spot number 0.Code Example
const numbers = [1, 2, 3];
console.log(numbers);Instructions
▼ ← Click the triangle to hide or reveal instructions.JavaScript Code Editor
Task Incomplete
Editor Input:
Editor Output:
[ ], you are telling the computer to keep them all together.Code Example
const pets = ["dog", "cat", "fish"];
console.log(pets);Instructions
▼ ← Click the triangle to hide or reveal instructions.JavaScript Code Editor
Task Incomplete
Editor Input:
Editor Output:
[ ] act like the walls of the carrier to keep everyone inside.Code Example
const names = ["Ana", "Ben", "Chris"];
for (let i = 0; i < names.length; i++) {
console.log(names[i]);
}
// Ana
// Ben
// ChrisInstructions
▼ ← Click the triangle to hide or reveal instructions.JavaScript Code Editor
Task Incomplete
Editor Input:
Editor Output:
i is like a finger pointing at the current spot in the list, starting at the very first name.names.length tells the computer exactly when to stop so it doesn't run past the end of the list.Code Example
const numbers = [
[1, 2],
[3, 4]
];
console.log(numbers[0][1]);
// 2Instructions
▼ ← Click the triangle to hide or reveal instructions.JavaScript Code Editor
Task Incomplete
Editor Input:
Editor Output:
0, so the first row is actually row 0!numbers[0][1], you are asking for the second item on the very first floor.Code Example
const groups = [
["Alice", "Bob"],
["Charlie", "Dana"]
];
console.log(groups[1][0]);
// CharlieInstructions
▼ ← Click the triangle to hide or reveal instructions.JavaScript Code Editor
Task Incomplete
Editor Input:
Editor Output:
groups[1][0], the first number chooses the row.