I know the solution exists, but I also got stuck on this one and thought I'd share some light on what I understand when instantly running a function.
Unless I missed additional items in the video, we are taught that and additional brace set at the end of the function calls the function instantly, but I dont recall it being mentioned that we can actually pass a variable in here as its technically the braces of the function being called. so by calling shift(queue)(input); for instance we now understand that its parsing the input variable to the the function in the currently addressed array index being assessed.
For a different view on the function I have composed this function. What happens is that each time we call shift the array size gets smaller. ie (it starts off with 4 items but slowly goes down to 0, while the for loop is increasing the index counter.)
the best view of the function I saw was actually saying check where the array is still greater than 0.
input = queue.shift()(input); i--;