Skip to content
Snippets Groups Projects
Commit d2d7823f authored by Jonathan Vitale's avatar Jonathan Vitale
Browse files

Update code for tutorial 2

parent eb7ba0cd
No related branches found
No related tags found
No related merge requests found
const gameState = {
playerWallet: 100,
currentBet: null
}
function collectBet(){
let currentBet;
let isValidBet = false;
//let counter = 0;
do {
console.log("please provide your bet")
currentBet = 10; // mocking up with a value
console.log(`You provided the bet being ${currentBet}`);
if (currentBet <= 0 || currentBet > gameState.playerWallet){
console.log('Your bet is not valid!');
//counter++;
} else {
isValidBet = true;
}
} while(!isValidBet) //&& counter < 4);
return currentBet;
}
function blackjack(){
// decide the bet, collect it
gameState.currentBet = collectBet();
// we deal the first 2 cards for the player
// check immediately that the player has blackjack
......@@ -29,4 +54,6 @@ function blackjack(){
// if player's score > dealer's score: player wins
// -> pay 2 times the bet
// end the game
}
\ No newline at end of file
}
blackjack();
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment