Skip to content
View in the app

A better way to browse. Learn more.

Tip.It Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Remake of Black Jack

Featured Replies

Anyhow, I decided I would remake my Black Jack game since I was so sad I lost my first one. My computer died and I lost it. :(

 

 

 

Click HERE to play my Black Jack game I made using JavaScript.

 

 

 

Click HERE to view blackjack.js.

 

 

 

*Links removed until I can find a host that Tip.It does allow.

 

 

 

Problems...

 

-Occasionally, the script needs to be stop by the user

 

-Two or more of the same card may appear

 

-Cards do not always display immediatly

 

-Heavily relies on prompts, alerts, and confirms

 

 

 

Future Additions...

 

-Determine winner, loser, or tied

 

-Money!

 

-More graphics + animations

 

-Score board

 

-Music :)

 

 

 

var cardNum = 0;

var cardDraw = 0;

var cardValue = 0;

var cardTotal = 0;

var user;

var comp;



document.write("
");

cardNum = Math.floor(Math.random() * 52 + 1);

document.write("");

if(cardNum >= 1)

 {

 if(cardNum <= 13)

   {

   cardValue = cardNum;

   }

 }

if(cardNum >= 14)

 {

 if(cardNum <= 26)

   {

   cardValue = cardNum - 13;

   }

 }

if(cardNum >= 27)

 {

 if(cardNum <= 39)

   {

   cardValue = cardNum - 26;

   }

 }

if(cardNum >= 40)

 {

 if(cardNum <= 52)

   {

   cardValue = cardNum - 39;

   }

 }

if(cardValue >= 11)

 {

 if(cardValue <= 13)

   {

   cardValue = 10;

   }

 }

if(cardValue == 1)

 {

 cardValue = window.prompt("You have an ace! Would you like the value of your ace to be 1 or 11?");

 if(cardValue == 1)

   {

   cardValue = 1;

   }

 if(cardValue == 11)

   {

   cardValue = 11;

   }

 else

   {

   cardValue = 1;

   }

 }

if(cardTotal == 21)

 {

 alert("Black Jack!");

 }

if(cardTotal > 21)

 {

 alert("Busted!");

 }

cardTotal = cardValue;

cardNum = Math.floor(Math.random() * 52 + 1);

document.write("");

if(cardNum >= 1)

 {

 if(cardNum <= 13)

   {

   cardValue = cardNum;

   }

 }

if(cardNum >= 14)

 {

 if(cardNum <= 26)

   {

   cardValue = cardNum - 13;

   }

 }

if(cardNum >= 27)

 {

 if(cardNum <= 39)

   {

   cardValue = cardNum - 26;

   }

 }

if(cardNum >= 40)

 {

 if(cardNum <= 52)

   {

   cardValue = cardNum - 39;

   }

 }

if(cardValue >= 11)

 {

 if(cardValue <= 13)

   {

   cardValue = 10;

   }

 }

if(cardValue == 1)

 {

 cardValue = window.prompt("You have an ace! Would you like the value of your ace to be 1 or 11?");

 if(cardValue == 1)

   {

   cardValue = 1;

   }

 if(cardValue == 11)

   {

   cardValue = 11;

   }

 else

   {

   cardValue = 1;

   }

 }

cardTotal = cardTotal + cardValue;

user = cardTotal;

alert("The user card total is " + cardTotal + ".");

if(cardTotal == 21)

 {

 alert("Black Jack!");

 }

if(cardTotal > 21)

 {

 alert("Busted!");

 }

while(cardDraw == 0)

 {

 cardDraw = confirm("Would you like to be hit?");

 if(cardDraw == true)

   {

   cardDraw = 0;

   cardNum = Math.floor(Math.random() * 52 + 1);

   document.write("");

   if(cardNum >= 1)

     {

     if(cardNum <= 13)

       {

       cardValue = cardNum;

       }

     }

   if(cardNum >= 14)

     {

     if(cardNum <= 26)

       {

       cardValue = cardNum - 13;

       }

     }

   if(cardNum >= 27)

     {

     if(cardNum <= 39)

       {

       cardValue = cardNum - 26;

       }

     }

   if(cardNum >= 40)

     {

     if(cardNum <= 52)

       {

       cardValue = cardNum - 39;

       }

     }

   if(cardValue >= 11)

     {

     if(cardValue <= 13)

       {

       cardValue = 10;

       }

     }

   if(cardValue == 1)

     {

     cardValue = window.prompt("You have an ace! Would you like the value of your ace to be 1 or 11?");

     if(cardValue == 1)

       {

       cardValue = 1;

       }

     if(cardValue == 11)

       {

       cardValue = 11;

       }

     else

       {

       cardValue = 1;

       }

     }

   cardTotal = cardTotal + cardValue;

   user = cardTotal;

   alert("The user total points is " + cardTotal + ".");

   if(cardTotal == 21)

     {

     alert("Black Jack!");

     cardDraw = 1;

     }

   if(cardTotal > 21)

     {

     alert("Busted!");

     cardDraw = 1;

     }

   }

 else

   {

   cardDraw = 1;

   }

 }

document.write("
");

cardTotal = 0;

cardNum = Math.floor(Math.random() * 52 + 1);

document.write("");

if(cardNum >= 1)

 {

 if(cardNum <= 13)

   {

   cardValue = cardNum;

   }

 }

if(cardNum >= 14)

 {

 if(cardNum <= 26)

   {

   cardValue = cardNum - 13;

   }

 }

if(cardNum >= 27)

 {

 if(cardNum <= 39)

   {

   cardValue = cardNum - 26;

   }

 }

if(cardNum >= 40)

 {

 if(cardNum <= 52)

   {

   cardValue = cardNum - 39;

   }

 }

if(cardValue >= 11)

 {

 if(cardValue <= 13)

   {

   cardValue = 10;

   }

 }

if(cardValue == 1)

 {

 if(cardTotal > 10)

   {

   cardValue = 1;

   }

 if(cardTotal <= 10)

   {

   cardValue = 11;

   }

 else

   {

   cardValue = 1;

   }

 }

if(cardTotal == 21)

 {

 alert("Black Jack!");

 }

if(cardTotal > 21)

 {

 alert("Busted!");

 }

cardTotal = cardValue;

cardNum = Math.floor(Math.random() * 52 + 1);

document.write("");

if(cardNum >= 1)

 {

 if(cardNum <= 13)

   {

   cardValue = cardNum;

   }

 }

if(cardNum >= 14)

 {

 if(cardNum <= 26)

   {

   cardValue = cardNum - 13;

   }

 }

if(cardNum >= 27)

 {

 if(cardNum <= 39)

   {

   cardValue = cardNum - 26;

   }

 }

if(cardNum >= 40)

 {

 if(cardNum <= 52)

   {

   cardValue = cardNum - 39;

   }

 }

if(cardValue >= 11)

 {

 if(cardValue <= 13)

   {

   cardValue = 10;

   }

 }

if(cardValue == 1)

 {

 if(cardTotal > 10)

   {

   cardValue = 1;

   }

 if(cardTotal <= 10)

   {

   cardValue = 11;

   }

 else

   {

   cardValue = 1;

   }

 }

if(cardTotal == 21)

 {

 alert("Black Jack!");

 }

if(cardTotal > 21)

 {

 alert("Busted!");

 }

cardTotal = cardTotal + cardValue;

comp = cardTotal;

alert("The computer total points is " + cardTotal + ".");

while(cardTotal < 17)

 {

 cardNum = Math.floor(Math.random() * 52 + 1);

 document.write("");

 if(cardNum >= 1)

   {

   if(cardNum <= 13)

     {

     cardValue = cardNum;

     }

   }

 if(cardNum >= 14)

   {

   if(cardNum <= 26)

     {

     cardValue = cardNum - 13;

     }

   }

 if(cardNum >= 27)

   {

   if(cardNum <= 39)

     {

     cardValue = cardNum - 26;

     }

   }

 if(cardNum >= 40)

   {

   if(cardNum <= 52)

     {

     cardValue = cardNum - 39;

     }

   }

 if(cardValue >= 11)

   {

   if(cardValue <= 13)

     {

     cardValue = 10;

     }

   }

 if(cardValue == 1)

   {

   if(cardTotal > 10)

     {

     cardValue = 1;

     }

   if(cardTotal <= 10)

     {

     cardValue = 11;

     }

   else

     {

     cardValue = 1;

     }

   }

 if(cardTotal == 21)

   {

   alert("Black Jack!");

   }

 if(cardTotal > 21)

   {

   alert("Busted!");

   }

 cardTotal = cardTotal + cardValue;

 comp = cardTotal;

 alert("The computer total points is " + cardTotal + ".");

 }

if(user <= 21)

 {

 while(user > comp)

   {

   cardNum = Math.floor(Math.random() * 52 + 1);

   document.write("");

   if(cardNum >= 1)

     {

     if(cardNum <= 13)

       {

       cardValue = cardNum;

       }

     }

   if(cardNum >= 14)

     {

     if(cardNum <= 26)

       {

       cardValue = cardNum - 13;

       }

     }

   if(cardNum >= 27)

     {

     if(cardNum <= 39)

       {

       cardValue = cardNum - 26;

       }

     }

   if(cardNum >= 40)

     {

     if(cardNum <= 52)

       {

       cardValue = cardNum - 39;

       }

     }

   if(cardValue >= 11)

     {

     if(cardValue <= 13)

       {

       cardValue = 10;

       }

     }

   if(cardValue == 1)

     {

     if(cardTotal > 10)

       {

       cardValue = 1;

       }

     if(cardTotal <= 10)

       {

       cardValue = 11;

       }

     else

       {

       cardValue = 1;

       }

     }

   if(cardTotal == 21)

     {

     alert("Black Jack!");

     }

   if(cardTotal > 21)

     {

     alert("Busted!");

     }

   cardTotal = cardTotal + cardValue;

   comp = cardTotal;

   alert("The computer total points is " + cardTotal + ".");



   }

 }

document.write("");

document.write("");

 

 

 

Please leave behind comments and/or suggestions.

aprzanimateddarkci0.gif

Unfortunately your link is not going to work as we no longer allow links to that specific host.

 

 

 

Just a tip though , 21 is not a blackjack , BlackJacK is ONLY if 21 is achieved in your first 2 cards :)

 

 

 

The best bet would probably be to add another variable of how many cards the user or dealer have and if cardTotal = 21 AND variable = 2 , BlackJack :)

 

 

 

Just besure to increment the variable by 1 with each card dealt and reset it at the begining of the script :)

I like to fart silently but deadly in movie theaters
Ard Choille says (11:41 PM):

I wouldn't dare tell you what to do m'dear

Not bad, all thought albosky is right, it is not a hard problem to fix. ill look forward to seeing some further progress with this :)

yourmysin.jpeg

Current Goals

80/80 Fletching

60/75 Woodcutting

97/100 Combat

  • Author

Aw, that's a shame. What host do you guys accept so people would be able to view and play the game?

 

 

 

Bleh, I forgot about that. One of my family told me to make a black jack game and it has been awhile since I have played it so I don't remember so much of it. Somebody told me that if you have 5 cards, you automatically win which I am not sure if that is true.

 

 

 

I'll fix that, but please tell me another free host I can use to share stuff I have made. :)

 

 

 

EDIT: I guess for now, I will just display blackjack.js which is the important part. :)

aprzanimateddarkci0.gif

Do you want me to upload it to yourmysin.info ?

yourmysin.jpeg

Current Goals

80/80 Fletching

60/75 Woodcutting

97/100 Combat

At least 21 is more fun then blackjack...^_^

  • Author
At least 21 is more fun then blackjack...^_^

 

 

 

At least 21? Is that another game?

 

 

 

Mysin, if that is your own site, make sure to give credit to me :lmfao:. Sure. Just post up the link here. :)

aprzanimateddarkci0.gif
At least 21 is more fun then blackjack...^_^

 

 

 

At least 21? Is that another game?

 

 

 

Mysin, if that is your own site, make sure to give credit to me :lmao:. Sure. Just post up the link here. :)

 

 

 

was only planning on it if you wanted to demonstrate it, but i would need the card images :P

yourmysin.jpeg

Current Goals

80/80 Fletching

60/75 Woodcutting

97/100 Combat

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.