let a = undefined;
function getComputerChoice(a) {
let n = (Math.random() * 3)
if (n <= 1){
return "rock"
} else if (n > 1 && n <= 2){
return "paper"
} else {
return "scissors"
}
};
let b = undefined
function getPlayerChoice(b) {
let c = prompt("Rock, Paper, or Scissors?").toLocaleLowerCase();
if (c === "rock"){
return ("rock")
}
else if (c === "paper"){
return ("paper")
}
else if (c === "scissors"){
return ("scissors")
}
else {
alert ("Input is not valid!")
}
};
let playerChoice = getPlayerChoice(b);
let computerChoice = getComputerChoice(a);
let computerScore = 1;
let playerScore = 1;
function checkWinner(computer, player, cscore, pscore) {
if (computer === "rock" && player === "rock"){
}
else if (computer === "rock" && player === "paper"){
pscore++;
}
else if (computer === "rock" && player === "scissors"){
cscore++;
}
else if (computer === "paper" && player === "rock"){
cscore++;
}
else if (computer === "paper" && player === "paper"){
}
else if (computer === "paper" && player === "scissors"){
pscore++;
}
else if (computer === "scissors" && player === "rock"){
pscore++;
}
else if (computer === "scissors" && player === "paper"){
cscore++;
}
else if (computer === "scissors" && player === "scissors"){
}
else {
}
};
function checkWin (computer, player) {
if (player === 6){
alert("You Win!")
}
else if (computer === 6){
alert ("You Lose!")
}
else {
}
};
do {
getPlayerChoice(b);
getComputerChoice(a);
checkWinner(computerChoice, playerChoice, computerScore, playerScore);
checkWin(computerScore, playerScore);
} while (computerScore <=6 && playerScore <= 6);
So far my playerChoice and computerChoice are recording properly, and after adjusting the output of parts of the checkWinner function, it seems to be looping properly in the do {}. This leads me to believe the part in checkWinner that is meant to increment (cscore++) isn't working properly and I haven't been able to figure out why. It is possible it is incrementing properly but I haven't been able to see that happening with the debugger. I used starting number 1 and ending number 6 as I was worried 0 was returning null somewhere in the code and that was the issue.