Skip to content

Commit

Permalink
Limited function to work on certain conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
Tshidycodes committed Apr 7, 2024
1 parent c09cdbc commit 08240fa
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,16 @@ startBtn.addEventListener("click", startGame);
let newBtn = document.querySelector("#new-btn");

function newCard() {
let newCard = getRandomCard();
sum += newCard; //adding a number to an existing variable
//Push new card to the cards array
cards.push(newCard);
console.log(cards);
renderGame();
//Shoudn't be able to draw cards when isAlive = false
//Should'nt be allowed to start the game with one card
//Only allow the player to get a new card if she isAlive and does not have BlackJack
if (isAlive === true && hasBlackJack === false) {
let newCard = getRandomCard();
sum += newCard; //adding a number to an existing variable
//Push new card to the cards array
cards.push(newCard);
console.log(cards);
renderGame();
}
}
newBtn.addEventListener("click", newCard);

0 comments on commit 08240fa

Please sign in to comment.