Stuck on Stand in Line

I’m not sure if I even understand the question correct or not but I have no confidence at all so sorry if the code is atrocious because I didn’t know what to do within 5 minutes. I have an idea of what I have to do but I don’t know how to put it all together if that makes sense.

Here you go

function nextInLine(arr, item) {
  // Your code here
  var arrayPush = arr.push();
  arrayPush = arr.shift();
  item = arrayPush;
  
  return item;  // Change this line
}

nextInline([2], 1);

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));

You’re close, but look at how Array.push() works.

How close am I? Which parts did I get correct? I’m still quite stuck to be honest.

Your line using push() is wrong. Look at how the push function works.

is this correct?

arr.push(item);

Ok this is what I done so far

function nextInLine(arr, item) {
  // Your code here
  arr.push(item);
  var removed = arr.shift();
  item = removed;
  
  
  return item;  // Change this line
}

nextInline([5,6,7,8,9], 1);

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));

That should work.

You can replace

item = removed;
  
  
  return item;  // Change this line

with

return removed;

I done it but it still says it ain’t working


function nextInLine(arr, item) {
  // Your code here
  arr.push(item);
  var removed = arr.shift();
  
  
  return removed;  // Change this line
}

nextInline([5,6,7,8,9], 1);

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));

Never mind I just completed it thank-you.