Better Aces

This commit is contained in:
2024-10-09 09:39:01 +02:00
parent ed91a4e0e9
commit 25fa32724b

12
main.js
View File

@@ -94,6 +94,18 @@ function cardsleft(){
function addScore(num){ function addScore(num){
playerCards.push(num); playerCards.push(num);
//? Filters out Aces
const withoutAces = playerCards.filter(e => e !== 'A');
const count = playerCards.length-withoutAces.length;
//? Adds the aces to the end
for(let i=0; i<count;i++){
withoutAces.push('A');
}
playerCards = [...withoutAces];
score = 0; score = 0;
playerCards.forEach(e => { playerCards.forEach(e => {
if(e === 'A'){ if(e === 'A'){