Stand in Line, I am getting error in code

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 

//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:

.push returns the new length of the array. Doing arr = arr.push(item) replaces the array in arr into a number (which doesn’t have a shift function, so you get that error).

arr.push(item); alone is enough. No assignment needed.

Thank you bro, I understand completely what you said. I’ve learned a little bit of java and going to java script is pretty weird because JavaScript uses generic variables called var which can be either arrays or strings or ints but with java you can’t go from one to the other. I thought I was telling the array “arr” to add item to it with that declaration to make it a longer array. Learning the nuances between the languages is fun but can be tricky!