JavaScript Arrays Worksheet
Question 1
What is the term for items that are stored in an array?
Items stored in an array are called "elements". Each element is assigned an index, in which it represents the position in the array. It begins at 0 for the first element then goes up by 1 for each increment.
Example:
Example:
let fruits = ["Apple", "Banana", "Cherry"];
console.log(fruits[0]); // "Apple" (Index 0)
console.log(fruits[1]); // "Banana" (Index 1)
console.log(fruits[2]); // "Cherry" (Index 2)
Question 2
The position number of an item in an array is called what?
As mentioned in question #1, this would be called an "index". See the example shown in problem #1 for reference.
Question 3
What is the index of the first value/element in an array?
As mentioned in question #1, each element is assigned an index, which represents the position in the array. It begins at 0 for the first element then goes up by 1 for each increment.
Question 4
True or False - The length of an array is always one greater than it's highest index.
True - the length of an array is always one greater than its highest index because indexes begin at 0.
Coding Problems
Coding Problems - See the 'script' tag below this h3 tag. You will have to write some JavaScript code in it.
You'll use the form below in one of the coding problems: