NEW
Font size
WorksheetsSkill #2 Array
Total questions: 12
Worksheet time: 9mins
1. Which statement correctly declares an array in JavaScript?
var array = [1, 2, 3];
var array = {1, 2, 3};
var array = (1, 2, 3);
var array = <1, 2, 3>;
How do you access the third element in an array named numbers?
numbers[2];
numbers[3];
numbers(3);
numbers{2};
Which of the following initializes an empty array?
var array = [];
var array = {};
var array = ();
var array = <>;
How can you iterate over an array named items using a for loop?
Which method adds one or more elements to the end of an array?
array.push(element);
array.pop();
array.shift();
array.unshift(element);
What will be the output of the following code?
"apple"
"banana"
"mango"
undefined
What does the following code return?
0
1
2
-1
What will be the output of the following code?
true
false
"apple"
undefined
What will be the output of the following code?
[2, 4, 6]
2
4
6
1
2
3
undefined
Which of the following code snippets correctly logs each number in the array numbers?
Which of the following code snippets correctly sorts the letters in ascending order?
Which of the following code snippets correctly sorts the numbers in descending order?
