Ok let me check .
From where you got the code ?
There is no swaparray function ?
What is the error you are getting ?
Actually I am seeing two buttons for Draw Pile and Discard piles .
If I am clicking Drawpile(blank) then popup coming variable undefined
Discard file button is not working
This Array.prototype.swap is not being called when I am clicking Draw button
You can try the code
I have just removed the alert and cleared syntax errors
Its very difficult to get the requirment I will open the question to others to help you