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

Tell us what’s happening:
What I should do?

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 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36.

Link to the challenge:

Method pop() removes last element in an array and returns it
Method shift() removes first element from an array and returns it.
so you should use
arr.pop(); assign it to popped variable,
arr.shift(); assign it to shifted variable.

1 Like