Files
Randell Dawson 1494a50123 fix(guide): restructure curriculum guide articles (#36501)
* fix: restructure certifications guide articles
* fix: added 3 dashes line before prob expl
* fix: added 3 dashes line before hints
* fix: added 3 dashes line before solutions
2019-07-24 13:29:27 +05:30

632 B

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

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


Problem Explanation

  • The .pop() method and .shift() method must be called and initialised using the popped and shifted variables to return the correct answer from the function.

Solutions

Solution 1 (Click to Show/Hide)
function popShift(arr) {
  let popped = arr.pop();
  let shifted = arr.shift();
  return [shifted, popped];
}

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