Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1playlist.pop() | Alet lastItem = items.pop(); | |
| 2queue.shift() | BRemoves the first person from the queue array and returns them | |
| 3Remove 2 items from the scores array, starting at index 1 | Cscores.splice(1, 2) | |
| 4Remove the last item and save it in a variable called lastItem | Dpop() always removes the last item and does not take an index. To remove the first item use fruits.shift() instead. | |
| 5fruits.pop(0); | Esplice with only an index removes everything from index 2 to the end. To remove just one item, give a count: names.splice(2, 1). | |
| 6names.splice(2); | FRemoves the last song from the playlist array and returns it |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
pop(), shift(), splice() — Array methods that remove items and change the original array: pop removes the last item, shift removes the first, splice(index, count) removes count items starting at index.let songs = ["Rock", "Pop", "Jazz"];
songs.pop();
console.log(songs);let line = ["Zoe", "Leo", "Isla"];
line.shift();
console.log(line);let nums = [10, 20, 30, 40];
nums.splice(2, 1);
console.log(nums); // [10, 20, 40]let scores = [5, 6, 7, 8, 9];
scores.splice(1, 2);
console.log(scores); // [5, 8, 9]let bag = ["pen", "ruler", "book"];
bag.splice(1, 1); // removes "ruler"
console.log(bag.length); // 2