title: Writing a functions that removes an array and adds to the list
body: <p>I'm currently learning Javascript at freecodecamp and am at the point where I'm learning about functions.</p>
  <p>I'm on a task that is asking me to right a type of <code>queue</code> that will removed the first item from the array, and replace it with another (at the end of the array).</p>
  <p>Here's what I have so far:</p>
  <pre><code>function nextInLine(arr, item) {
    // Your code here
    array = [];
    array.shift(arr);
    array.push(item);
    return arr;  // Change this line
  }
  
  // Test Setup
  var testArr = [1,2,3,4,5];
  
  // Display Code
  console.log(&quot;Before: &quot; + JSON.stringify(testArr));
  console.log(nextInLine(testArr, 6)); // Modify this line to test
  console.log(&quot;After: &quot; + JSON.stringify(testArr));
  </code></pre>
  <p>However when run with the test setup it out puts:</p>
  <blockquote>
  <p>Before: [1, 2, 3, 4, 5]</p>
  <p>After: [1, 2, 3, 4, 5]</p>
  </blockquote>
  <p>I'm confused as all get out.. How would I accomplish this task?</p>
  <p>Actual task:</p>
  <blockquote>
  <p>In Computer Science a queue is an abstract Data Structure where items are kept in order. New items can be added at the back of the queue and old items are taken off from the front of the queue.</p>
  <p>Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.</p>
  </blockquote>