I am writing a function queue which takes an array (arr) and a number (item) as arguments. Then I add the number to the end of the array, and remove the first element of array. The function should then return the element that was removed.
function queue(arr, item) {
arr.push(item);
var removedItem = arr.shift();
return removedItem;
}
Then i get this error: RangeError: maximum call stack size exceeded.
Can anyone explain me what is going wrong? In my eyes (beginner), the code looks okay? Thanks in advance!
queuecalled infinitely? maybe inside a l0000000p - Tushar