Function not working as expected

Ok so I’ve figured out a way of doing it. A little messy but it works.
I pass a sprite into the function,
I also define/set a sprite in the function, then change the image of the function sprite to that of the one in the parameter.
And then destroy the parameter sprite.

I would actually like to pass in an animation to the function. Is that possible? I can add them all to an array and the iterate through it outside of the function but my idea was to have this function create multiple rows of different sprites.

Thanks for your help