Array Methods Flashcards
1
Q
Use the correct Array method to remove the last item of the fruits array.
var fruits = [“Banana”, “Orange”, “Apple”];
A
fruits.pop()
2
Q
Use the correct Array method to add “Kiwi” to the fruits array.
var fruits = [“Banana”, “Orange”, “Apple”];
A
fruits.push(“Kiwi”);
3
Q
Use the splice() method to remove “Orange” and “Apple” from fruits.
var fruits = [“Banana”, “Orange”, “Apple”, “Kiwi”];
A
fruits.splice(1, 2);
4
Q
Use the correct Array method to sort the fruits array alphabetically.
var fruits = [“Banana”, “Orange”, “Apple”, “Kiwi”];
A
fruits.sort();