Jump to content
xisto Community
Sign in to follow this  
kvarnerexpress

Javascript Blackjack...

Recommended Posts

I decided that I wanted to make a Javascript version of
Black Jack, so that I could play it on my desktop.

This is what I've got so far...


Code:

function deal_Cards(){var p='jsKid', c='Computer';document.frm_blackjack.playerName.value  = p;document.frm_blackjack.computerName.value	= c;var c_Cards	= new Array();var c_Total	= 0;var p_Cards	= new Array();var p_Total	= 0;var cardsLeft	= 52;var suits	= new Array();	if (p && c)	{  for (var s=0; s <= 3; s++)  {  	suits[s] = new Array('A','2','3','4','5','6','7','8','9','10','J','Q','K');  	for (var n=0; n <= suits[s].length-1; n++)  	{    var set = suits[s][n];    // document.write( set + '<BR>');  	}  }	}}window.onload = deal_Cards;window.onbeforeunload = function() { document.frm_blackjack.reset(); }

where I am stuck at, is how do I randomize the cards that
are to passed to the players?

Putting your code in the code box helps other users to read it easier. Please remember to do this next time. Thank you. :)
Edited by snlildude87 (see edit history)

Share this post


Link to post
Share on other sites

Maybe this will help you:

no=Math.random()*52document.write(Math.round(no))
You would have to remove that card from the deck though. Can you post the followups of your code here?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.