Skip to content

Commit e770ff2

Browse files
committed
added ace
1 parent e6a1776 commit e770ff2

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

blackjack/index.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ let message = "";
66
let isAlive = false;
77
let hasblackJack = false;
88
let playerInfo = {
9-
name: "Anurag",
9+
name: "",
1010
chips: 0
1111
}
1212

@@ -96,9 +96,6 @@ function resetGame() {
9696
}
9797

9898
function validateInfo() {
99-
console.log(playerNameEL.value, playerChipsEL.value);
100-
console.log(playerInfo.name, playerInfo.chips);
101-
10299
if (playerNameEL.value === "") {
103100
alert("Please enter your name!");
104101
return;
@@ -119,5 +116,12 @@ function validateInfo() {
119116
}
120117

121118
function getRandomCard() {
122-
return Math.floor(Math.random() * 13) % 10 + 2;
119+
let randomNumber = Math.floor(Math.random() * 13) % 10 + 1;
120+
121+
if (randomNumber === 1) {
122+
const isAce = confirm("You got an Ace! Do you want it to be 1\nIf cancel, it will be 11");
123+
randomNumber = isAce ? 1 : 11;
124+
}
125+
126+
return randomNumber;
123127
}

0 commit comments

Comments
 (0)