JAVASCRIPT · ОСНОВЫ · LESSON 13

Take one element.

Array index · about 12 minutes

Learning with progressRead the summary for free. To save the work, log in to the account.
STEP 1

The score starts from scratch.

The first element of the array lies at address 0, the second at address 1.

const nums = [10, 20, 30];
console.log(nums[1]);

✦ There'll be 20.

STEP 2

Don't go over the edge.

In an array of three elements, there are addresses 0, 1 and 2. Address 3 is overseas.

const nums = [10, 20, 30];
console.log(nums[2]);

✦ That's the last number: 30.

IN-CLASS PRACTICE

Type the code yourself

Type an example manually. Check the names, brackets and signs.

const nums = [10, 20, 30];
console.log(nums[1]);
Open the editor for class work
HOMEWORK

Solve it yourself

Create const fruits as an array of words «яблоко», «груша», «банан». Put the second fruit through its index.

The answer is hidden. Use similar examples from the lesson notes.

Opening up your homework