.push() : pushs the element in the end of an array
.pop() : pops the element in the end of an array
.shift(): removes the first element of an array
.unshift(): adds the element at the beginning of the array.
the local variable takes precedence over the global variable.
arr.push(item);
var removed = arr.shift(item);
return removed; // Changed
}
// Test Setup
var testArr = [1,2,3,4,5];
// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 10)); // Modified
console.log("After: " + JSON.stringify(testArr));