Arrays – Mutating Methods, online

Six activities your students do on their own devices. See who's finished, and their scores.

Arrays – Mutating Methods in one minute

What students need to know

unshift() inserts the value at the beginning of the array. shift() removes and returns the array's first element.

push() adds one or more elements to the end of the array. push, pop, shift, and unshift all mutate the original array.

Mistakes students make

  • Use push(), not add(), to add to the end of an array.
  • Use pop(), not remove(), to remove the last element.
  • push() needs parentheses to actually call the method.
  • 'pop' must be lowercase - a capital P causes an error.
PREVIOUS · MODULE 23for...of Loops
YOU ARE HERE · MODULE 24Arrays – Mutating Methods
NEXT · MODULE 25Arrays – forEach()

Discover other journeys with this module

What students will learn in this module

Every question in Module 24

Quick questions

  1. Does push() add an element to the end of an array?AYesBNo
  2. Does pop() remove the first element of an array?ANoBYes
  3. Does unshift() add an element to the start of an array?ANoBYes
  4. Does shift() remove the first element of an array?ANoBYes
  5. Do these methods change the original array?AYesBNo

Key terms

Students type the meaning of:

  • push()

Match the pairs

nums.push(4)Match it to what it does
nums.pop()Match it to what it does
Adds an element to the start of an arrayMatch it to what it does
Removes the first element from an arrayMatch it to what it does
a.add(3);Match it to what it does
b.remove();Match it to what it does

Fill in the blanks

  1. nums.____(4);

    Hint: Type the method that adds an element to the end of an array.

  2. nums.___();

    Hint: Type the method that removes the last element of an array.

  3. nums._______(1);

    Hint: Type the method that adds an element to the start of an array.

  4. let first = nums._____();

    Hint: Type the method that removes the first element of an array.

  5. scores.____(90);

    Hint: Type the method that adds an element to the end of an array.

Spot the error

Question 1

Aa.add(3);Blet a = [1, 2];Cconsole.log(a);

Question 2

Alet b = [1, 2, 3];Bb.remove();Cconsole.log(b);

Question 3

Alet c = [2, 3];Bconsole.log(c);Cc.push;

Question 4

Alet d = [1, 2, 3];Bconsole.log(d);Clet e2 = 5;Dd.Pop();

Question 5

Alet e = [2, 3];Bconsole.log(e);Clet f2 = 1;Dconsole.log(f2);Ee.Push(1);