#Help Fixing Bugs

9 messages · Page 1 of 1 (latest)

livid crescent
#

Hello! This was my first BIG project involving JavaScript, where I tried to implement new features not assigned as a homework in the blackjack course on Scrimba. There are however many bugs that aren't intended and I do not know how to fix them. A small code review and some tips on how to organize my code better would also be appreciated. Thank you if anyone decides to respond.

Here is the link to the JavaScript file on Github. 6989_cat_smile
https://github.com/ZascuOfficial/Scrimba-Blackjack_App/blob/main/js/main.js

GitHub

Contribute to ZascuOfficial/Scrimba-Blackjack_App development by creating an account on GitHub.

fluid cedar
#

Hi @livid crescent I'm happy to help you through - I've downloaded your project and it seems to run without any major issues. You say there are lots of bugs in here but without knowing how your game is intended to play it's hard to say what to suggest for "fixing" it. If you could detail what you expect to happen and then detail the bugs it would help us to fix it.

One thing I will say is that when programming a game, you need to put yourself in the shoes of someone who has never played blackjack before, so at each point you need to make it clear to the user which actions they should be using at any one time. For example, am I supposed to place a bet before pressing the "start game" button? If not then I SHOULDN'T be able to place any bets until the "start game" button has been pressed. You can do this by disabling the buttons that can't be clicked.

Similarly with the "new card" and "withdraw" buttons. Right now I can press both those buttons before pressing the "start game" button. Pressing the "new card" button at this time does nothing, whereas pressing the "withdraw" button results in the house winning without me getting any cards at all.

This is partly why games development is so hard, because you have to think of every single stupid thing the user could possibly do, and account for it.

glass basin
#

Good start. The logic seems pretty sound. A few comments: UI is a bit confusing, I'm not really sure how to play this game. I don't really know if I've won the round or not. If I win, my balance doesn't update? I would take a look at other blackjack games and try to emulate the same interface and logic. General comments on the code: CSS: Apply a class for reused styling. Reuse the class don't use IDs. JS: Use strict inequality operator https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Strict_inequality. Use conditional colors (red -lose / green - win) on the sum to make clear who has won / lost the round.

#

Can you make a list of the bugs with a description of expected behaviour / current behaviour? 1. Expected: User's balance updates after winning the round. Current: Does not update.

livid crescent
livid crescent
livid crescent
#

I have changed all the variables to be properties for objects to organize the code, and made a function that initializes the cards and the sums of the cards