Tell us what’s happening:
Can anyone help me understand why this is happening?
This code works when I remove the first arr= and when I include it, it gives me line “arr.shift is not a function”
Your code so far
function nextInLine(arr, item) {
// Your code here
arr= arr.push(item);
var removed= arr.shift();
return removed;
// Change this line
//arr.push(item);
//var temp = arr.shift();
//return temp;
}
// 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 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2683.0 Safari/537.36
.
Link to the challenge: