4/6/2022

Juego De Blackjack En Javascript

11

I'm having trouble creating a Blackjack program to display in an HTML page using an external Javascript file. I don't need to label my cards, and I've created a dealer that will always be between 17-21 in score. I'm unsure of what parts of my code is completely wrong and what needs a bit of tweaking. Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube. Bonus valid for 14 days. 30 Spins on preselected games Juego De Blackjack En Javascript will be credited instantly + then 30 per day for 9 days. Free Spins valid for 72 hours from credit. Max Free Spins winnings £100. Skrill + Neteller Juego De Blackjack En Javascript excluded. Always refer to Bonus Terms. En jQuery Love, que como su original nombre indica es un blog de amantes del jQuery y empiezan fuerte, ya que en su primer post nos presentan jQuery Blackjack, el famoso juego de cartas convertido en sentencias Javascript para que puedas jugar online y de paso, mostrar el potencial de Javascript.

In general, I think you did a good job overall. That is, getting the game logic to run without serious issue. There were a couple of errors that caused the game to not run correctly. One was if the player gets a blackjack the game exits without prompting the user for further action:

LOGIC

I shortened the code up here but you can see since you do your check outside of 'hand-loop' and call break you will exit the program. This goes for if there is a push on blackjack too.

Exhausting the deck, where you only reset the deck if the player hits. This is because of how you are drawing cards by calling .pop.

If you keep standing on every turn you will eventually get an IndexError. You could just call random.choice on the deck and not have to worry about it while using some other condition to reset the deck:

STYLE

There are some style issues here too. These usually come down to personal preferences but if you are having others read your code its best to stay close to pep8 which is a general consesus for helpful style choices.

JavascriptJuego De Blackjack En Javascript

OOP

You also make use of global variables quite a bit. Usually using globals are considered bad practice. What you could do is think about where each one of these functions and variables would logically make sense to be grouped together. Then create a class to encapsulate the variables and functions, adhering to good OOP principles. You do this to a certain degree but you could further it by adding in the globals too:

CODE DUPLICATION

You also have several spots of code duplication. Keeping with DRY (don't repeat yourself) you could use a loop or recursion to cut down on some of this:

Where you could pass in a list or any other kind of iterable and loop for them:

There are places where you are using counters too where iterating over the list itself or a range would be fine:

would be:

STANDARD LIBRARY

One of the great things about Python is that there are a rich collection of libraries/modules already made by really intelligent people. Use this to your advantage and get to know different modules and what they offer:

becomes:

Juego De Blackjack En Javascript Gratis

Where you can use itertools.product to create a cartesian product

Juego De Blackjack En Javascript W3schools

I re-wrote your program by creating a different game-loop and making a couple of different classes:

sermadene1971.netlify.com – 2021