diff --git a/index.js b/index.js index adcb4c3..3704f6c 100644 --- a/index.js +++ b/index.js @@ -54,8 +54,8 @@ function restart() { NewLine(logo, false); for (let i = 0; i < 2; i++) { user_cards.push(deal_card()); - computer_cards.push(deal_card()); } + computer_cards.push(deal_card()); newRound(); } @@ -188,17 +188,18 @@ function calculate_score(cards) { return cards.reduce((partialSum, a) => partialSum + a, 0); } +// new compare function. Checks for computer blackjack function compare(user_score, computer_score) { if (user_score > 21 && computer_score > 21) { return "You went over. You lose 😤"; } - if (user_score == computer_score) { - return "Draw 🙃"; - } else if (computer_score == 0) { + if (computer_score == 0) { return "Lose, opponent has Blackjack 😱"; } else if (user_score == 0) { return "Win with a Blackjack 😎"; + } else if (user_score == computer_score) { + return "Draw 🙃"; } else if (user_score > 21) { return "You went over. You lose 😭"; } else if (computer_score > 21) {