The problem I'm having is with Aces. My code sends it straight to the else statement, which is not correct.
Here is the link to the Blackjack Strategy Chart:
http://www.blackjackinfo.com/bjbse.php
<head>
<title>Exercises for If Statements</title>
</head>
<body>
<script type="text/Javascript">
<!--
var linebreak = "<br/>"
var Y = parseFloat( prompt("Enter your hand","") );
var D = parseFloat( prompt("Enter the dealer's hand", "") );
if (Y <= "8"){
document.write("Hit<BR>");
}
else if(Y == "9" && (D == "2" || D == "7" || D == "8" || D =="9" || D == "10" || D == "A")){
document.write("Hit<BR>");
}
else if(Y == "9" && (D == "3" || D == "4" || D == "5" || D == "6")){
document.write("Double<BR>");
}
else if(Y == "10" && (D == "2" || "3" || "4" || "5" || "6" || "7" || "8" || "9")){
document.write("Double<BR>");
}
else if(Y == "10" && (D == "10" || "A")){
document.write("Hit<BR>");
}
else{
document.write("This hand does not exist.");
}
//-->
</script>
</body>
</html>
*** Edit ***
Please use code tags when posting code!
This post has been edited by GunnerInc: 22 June 2012 - 04:28 PM
Reason for edit:: Added code tags

New Topic/Question
Reply


MultiQuote







|