I am learning JS, in the Stand in Line this was my solution:
function nextInLine(arr, item) {
// Your code here
var c = arr[0];
for(i = 0; i < arr.length; i++){
arr[i] = arr[i+1];
}
arr[arr.length-1] = item;
return c; // Change this line
}
or this code
function queue(arr, item) {
// Your code here
arr.push(item);
return arr.shift();; // Change this line
}
When I did it a completily forgot about push and shift function.
Also, I don’t understand why if the array is empty, the functions returns 1. It is supossed to return the element that was deleted from the array.