var card_num=54; function wash_card(card_num) { var card=[], tmp=[], index; for(var i=0;i<card_num;i++){ tmp[i]=i+1; } for(var i=0;i<card_num;i++){ index=Math.floor(Math.random()*(card_num-i)); card[i]=tmp[index]; tmp.splice(index,1); } return card; } console.log(wash_card(card_num));