Tell us what’s happening:
Hi, I have a question, I wanna know why is not the same write this:
function nextInLine(arr, item) {
var queue = arr.push(item)
var rItem = arr.shift()
return rItem;
}
and write this:
function nextInLine(arr, item) {
var aux = item
item = arr[0]
arr[0] = item
return item;
}
this is my first time trying to code, please help me! ^^
Your code so far
function nextInLine(arr, item) {
// Your code here
var queue = arr.push(item)
var rItem = arr.shift()
return rItem; // Change this line
}
// 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));
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:57.0) Gecko/20100101 Firefox/57.0
.
Link to the challenge:
https://www.freecodecamp.org/challenges/stand-in-line