console.log("Let the games begin!"); var wins = 0; var ties = 0; var losses = 0; function startGame() { var userChoice = prompt("Rock, Paper, or Scissors to play against the computer!"); console.log("You've made your choice!", userChoice); var options = ["Rock", "Paper", "Scissors"]; var ranDecimal = Math.floor(Math.random) * options.length; var ranInt = Math.floor(ranDecimal); var computerChoice = options[ranInt]; console.log("Computer Has Chosen ", computerChoice); if (userChoice === computerChoice){ alert("tie game") ties++; } else if ( (userChoice==="Rock" && computerChoice==="Scissors") || (userChoice==="Paper" && computerChoice==="Rock") || (userChoice==="Scissors" && computerChoice==="Paper") ){ alert("You won the game"); wins++; } else { alert("You Lost the Game!") losses++; } alert("total: ",+ "wins: "+ wins,+"ties: ",+ ties,+ "losses: ",+ losses); var playAgain = confirm("play again??"); if (playAgain) { startGame(); } } startGame();
I got this,…
https://mobdro.onl/