Rock, Paper, Scissors

//play rock paper scissors
//human enters in number 0 1 or 2, 
//computer generates similar value
//compare with a series of nested if statements
//keep track of scores
//go on until somebody gets three points
//scoring chart:
//  scissors cut paper
//  paper covers rock
//  rock breaks scissors

//generate some constants to make logic easier to follow
var ROCK = 1;
var PAPER = 2;
var SCISSORS = 3;

//constants for boolean values
var TRUE = -1;
var FALSE = 0;

//main variables
var humanGuess = 0;
var compGuess = 0;
var humanScore = 0;
var compScore = 0;

var keepGoing = TRUE;


while (keepGoing == TRUE){
//for each round:

  //generate human guess
  humanGuess = prompt("1) Rock, 2) Paper, or 3) Scissors");
  //make sure we have an integer to work with
  //we'll probably want better error correction later
  humanGuess = parseInt(humanGuess);
  
  //alert ("Human said " + humanGuess);
  
  //generate computer guess
  compGuess = Math.random();
  //alert("Computer said " + compGuess);
  compGuess = compGuess * 3;
  //alert("Computer said " + compGuess);
  //parseInt did NOT work correctly here!!
  compGuess = Math.floor(compGuess) + 1;
  //alert("Computer said " + compGuess);

  //translate computer response to english
  if (compGuess == ROCK){
    alert ("Computer said rock");
  } // end if

  if (compGuess == PAPER){
    alert ("Computer said paper");
  } // end if

  if (compGuess == SCISSORS){
    alert ("Computer said scissors");
  } // end if


   
  //do comparisons
  if (humanGuess == ROCK){
    if (compGuess == ROCK){
      //do nothing
      alert("Tie!!");
    } // end comp rock if
  
    if (compGuess == PAPER){
      compScore++;
      alert("paper covers rock");
    } // end comp paper if
  
    if (compGuess == SCISSORS){
      humanScore++;
      alert("rock breaks scissors");
    } // end comp scissors if
  } // end human rock if
  
  if (humanGuess == PAPER){
    if (compGuess == ROCK){
      humanScore++;
      alert("paper covers rock");
    } // end comp rock if
  
    if (compGuess == PAPER){
      //do nothing
      alert("Tie!!");
    } // end comp paper if
  
    if (compGuess == SCISSORS){
      compScore++;
      alert("Scissors cut paper");
    } // end comp scissors if
  } // end human rock if
  
  if (humanGuess == SCISSORS){
    if (compGuess == ROCK){
      alert("rock breaks scissors");
      compScore++;
    } // end comp rock if
  
    if (compGuess == PAPER){
      alert("Scissors cut paper");
      humanScore++;
    } // end comp paper if
  
    if (compGuess == SCISSORS){
      //do nothing
      alert("Tie!!");
    } // end comp scissors if
  } // end human rock if
  
  //print out current score
  alert ("Score - Human: " + humanScore + ", Computer: " + compScore);
  
  if (humanScore >=3){
    alert ("You win!!!");
    keepGoing = FALSE;
  } // end if
  
  if (compScore >=3){
    alert ("computer wins!!!");
    keepGoing = FALSE;
  } // end if
  
} // end while loop