JavaScript básico - Permanece en línea

Tell us what’s happening:

Describe tu problema en detalle aquí.
La primera parte del problema queda resuelto pero me falta las otras dos:

  • nextInLine([2], 1) debe devolver 2

  • Esperando:nextInLine([5,6,7,8,9], 1) debe devolver 5

No tengo ni idea por donde seguir. he probado difentes cosas y no funcionan.

Your code so far

function nextInLine(arr, item) {
  // Cambia solo el código debajo de esta línea

 testArr.push(item);

  return testArr.shift();
  // Cambia solo el código encima de esta línea
}

// Configuración
let testArr = [1, 2, 3, 4, 5];

// Muestra el código
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6));
console.log("After: " + JSON.stringify(testArr));

Your browser information:

El agente de usuario es: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36

Challenge Information:

JavaScript básico - Permanece en línea

use the function parameters, not global variables

It is not clear to me where I can modify the code. I have tried several things.
function nextInLine(arr, item) {

// Cambia solo el código debajo de esta línea

testArr.push(item);

return testArr.shift();

// Cambia solo el código encima de esta línea

}

// Configuración

let testArr = [1, 2, 3, 4, 5];

// Muestra el código

console.log("Before: " + JSON.stringify(testArr));

console.log(nextInLine(testArr, 6));

console.log("After: " + JSON.stringify(testArr));

console.log("Before: " + JSON.stringify(testArr));

console.log(nextInLine([2], 1));

console.log("After: " + JSON.stringify(testArr));

console.log("Before: " + JSON.stringify(testArr));

console.log(nextInLine([5,6,7,8,9], 1));

console.log("After: " + JSON.stringify(testArr));

there is written where you can edit the code, but use only the parameters of the function, arr and item, not a global variable like testArr

Thanks, Now the code run.