Hi, I am working on an assignment for my CSC class and I am having trouble with the code. I have an idea on what I would like to do. The purpose of the assignment is to make a simple game of craps. First time you roll if you land on a 7 or 11, you win automatically. If you roll on 2, 3, or 12, automatic loss. Anything else keep rolling until you and on a 7, then you automatically lose. If you can look at my code and let me know what you think of it, I truly appreciate it.
// JavaScript source code
// First going to create the bet function
function BtnBet_onclick() {
//create variables
var die1;
var die2;
var rolls = 1;
var bet = document.getElementById("txtBet").value;
var results = "";
var NetMoney;
var MoneyWon
var MoneyLoss;
alert("1");
// Roll 'em, Boys!
die1 = (Math.floor(Math.random() * 6) + 1);
die2 = (Math.floor(Math.random() * 6) + 1);
var sum = die1 + die2;
sum = die1 + die2;
results += die1 + " + " + die2 + "==>" + sum + "\n";
document.getElementById("txaResults").value = results;
switch (results) { //This is for the first roll
case 7:
case 11:
alert("Winner!")
MoneyWon += bet;
NetMoney += MoneyWon;
document.getElementById("txtmw").value = MoneyWon;
document.getElementById("txtnm").value = NetMoney;
break;
case 2:
case 3:
case 12:
alert("Sorry, try again!");
MoneyLoss += bet;
NetMoney = NetMoney - MoneyLoss;
document.getElementById("txtml").value = MoneyLoss;
document.getElementById("txtnm").value = NetMoney;
break;
case 4: //This is where I am thinking about making another loop.
case 5:
case 6:
case 8:
Case 9:
case 10:
alert("yo");
break;
}
}