Yet another one.. Blackjack game built using JavaScript, Love you Codecademy

I had no idea what blackjack is (I knew it was some kind of card game), but now, thanks to the step by step from ground zero instructions given by Codecademy, I have a functional Blackjack architecture that works just as intended.

I am still not well verse with Blackjack, but I now know the basics of it and can talk about it with people rather than being purely unknown to it.
And guess what, What better way to learn about Blackjack then building it ourselves using a programming language!

Here’s the code that I wrote through Codecademy’s instructions (that was like pseudo code for me as I was completely unknown to Blackjack game)

// Our deal function will return a random card
var deal = function() {
  card = Math.floor(Math.random()*52+1);
  return card;

// Deal out our first hand
var card1 = deal();
var card2 = deal();

// This function takes a card as a parameter and returns the value
// of that card
var getValue = function(card) {
  // if its a face card, number should be set to 10        
    if (card % 13 === 1)
            return 11;
  // What if it's an ace?
    else if (card % 13 === 0 || card % 13 === 11 || card % 13 === 12)
            return 10;
  // Otherwise, we just want its number value
            return card % 13;
// Score the hand
function score() {
  return getValue(card1) + getValue(card2);

console.log("You have cards " + card1 + " and " + card2 +
        " for a score of " + score(card1, card2));

Expect me soon with more adventures on Codecademy.. Till then adios amigos!

This entry was posted in Code Academy, JavaScript and tagged , , , , , , , , , , , , , , , , . Bookmark the permalink.

2 Responses to Yet another one.. Blackjack game built using JavaScript, Love you Codecademy

  1. aaousr says:

    javascript blackjack coders look away now. just look away.

    this is so far from being a functional javascript blackjack architecture, it would be like nasa trying to land a man on the moon using steam-engine technology. indeed, it is barely javascript, let alone an architecture.

    i’m astonished it ranked so high on google’s javascript blackjack results.


    • Hey thanks for the honest feedback.
      I am currently learning more software engineering principles and architecture, your feedback is of immense help towards my further growth in this discipline.
      Super thanks again! 🙂

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s