Stand in Line Help I don't understand

Tell us what’s happening:

Your code so far


function nextInLine(arr, item) {
  // Your code here
  var nextInLine = ([2], 1);
  var nextInLine = ([5,6,7,8,9], 2);
  return item = [1, 2]; // Change this line
}
// Test Setup
var testArr = [1,2,3,4,5];
// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 10), testArr[4]); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36 OPR/54.0.2952.54.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/stand-in-line/

You are given an array called arr and a new item to add to the array.
Your code should add the item to the end of the array and take out the first item in the array at index 0. Right now your code is not using arr or item at all. Review javascript arrays to learn how to add and remove things from them.

2 Likes

Hi,
You might need to go back to review some previous challenges. This challenge builds on what you learned in the last 15 or so challenges.

These two lines of code pass array [1,2,3,4,5] and number 6 to your function

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

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

In your function those two arguments are named arr and item


// Write a function nextInLine which takes 
// an array (arr) and a number (item) as arguments.
function nextInLine(arr, item) {
     // Add the number to the end of the array, 
     // then remove the first element of the array.

      return  ?  // function should then return the element that was removed.
}

In previous challenges you used some “built in” array methods to manipulate arrays

Listing and examples of all array methods - bookmark this one!

Good luck

2 Likes