Try this exercise. Fill in the missing part by typing it in.
To access an element at a specific index in an array, you can use array indexing. For example, if we have an array numbers
with elements [1, 2, 3, 4, 5]
, we can access the element at index 2 by using numbers[2]
. This will return _.
The code snippet below demonstrates accessing an array element at a specific index:
SNIPPET
1const numbers = [1, 2, 3, 4, 5];
2const element = numbers[2]; // Accessing the element at index 2
3console.log(element); // Output: 3
Explain why the code above outputs the value 3.
Write the missing line below.