I have the following 2 functions:
function undo(){
var card = discardPile.pop();
if( card.col != -1 ){
sendToCol( card );
}else{
sendToDrawPile( card );
}
cardsLeft();
}
function undowaste(){
var card = wastePile.pop();
if( card.col != -1 ){
sendToCol( card );
}else{
sendToDrawPile( card );
}
cardsLeft();
}
They are the same except for the card value. So I was wondering, can I merge these 2? And how to do this?
EDIT: I use this function to execute both:
function restart(){
if( discardPile.length){
undo();
setTimeout(restart,75);
}if( wastePile.length){
undowaste();
setTimeout(restart,75);
}
}
Thanks