Remove Items from an Array with pop() and shift()

Tell us what’s happening:

Your code so far

function popShift(arr) {
  let popped; // change this line
  let shifted; // change this line
  return [shifted, popped];

// do not change code below this line
console.log(popShift(['challenge', 'is', 'not', 'complete']));

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:61.0) Gecko/20100101 Firefox/61.0.

Link to the challenge:

What exactly is your question related to this challenge?

Hello there,

The pop() method will remove the LAST item from an array and the shift() method will remove the FIRST item from an array.


let names = ['Mike', 'Ian', 'Adrian']
names.shift() // removes Mike from the Array
names.pop() // removes Adrian from the Array

More Info:

1 Like