mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-01-14 21:07:33 -05:00
620 B
620 B
title, localeTitle
| title | localeTitle |
|---|---|
| Remove Items from an Array with pop() and shift() | Eliminar elementos de una matriz con pop () y shift () |
Eliminar elementos de una matriz con pop () y shift ()
- El
.pop()método y.shift()método debe ser llamado y inicializado usando lospoppedyshiftedvariables para devolver la respuesta correcta de la función.
Solución:
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']));