DEV Community

Discussion on: Remove Items from Arrays with .shift() & .pop() Methods

Collapse
 
davoe549 profile image
Sistawan

function popShift(prob) {
let shifted = prob.shift();
let popped = prob.pop();
return [shifted, popped];
}

console.log(popShift(['Problem', 'is', 'not', 'solved']));

Collapse
 
swarnaliroy94 profile image
Swarnali Roy

Absolutely correct 👍👍