9/9 I need help with my creation- it says SyntaxError: Unexpected end of input


#1

    var gamePlays = true;
    var yourPoints = 0;
    var computerPoints = 0;
    while (gamePlays) { 
    var userChoice = prompt("Do you choose rock, paper or scissors?").toLowerCase();
    console.log("You choose: " + userChoice);
    var computerChoice = Math.random();
    if (computerChoice < 0.34) 
    {
    	computerChoice = "rock";
    } 
    else if (computerChoice < 0.67)
    {
    	computerChoice = "paper";
    }
    else 
    {
    	computerChoice = "scissors";
    };
    console.log("Computer choose: " + computerChoice);
    var compare = function(choice1,choice2)
    {
        if (choice1 === choice2)
        {
            return "The result is a tie!";
        }
        else if (choice1 === "rock")
        {
            if (choice2 === "scissors")
            {
                return "You win this round!";
            }
            else
            {
                return "Computer win this round!";
            }
        }
        else if (choice1 === "paper")
        {
            if (choice2 === "rock")
            {
                return "You win this round!";
            }
            else 
            {
                return "Computer win this round!";
            }
        }
        else if (choice1 === "scissors")
        {
            if (choice2 === "rock")
            {
                return "Computer win this round!";
            }
            else
            {
                return "You win this round!";
            }
        }
    };
    compare(userChoice,computerChoice);
    console.log(compare(userChoice,computerChoice));
    if (compare(userChoice,computerChoice) === "The result is a tie!") {
        alert("Try again!");
    } else if (compare(userChoice,computerChoice) === "You win this round!") {
        yourPoints++;
    } else {
        computerPoints++;   
    };
    console.log("Your Points:" + yourPoints);
    console.log("Computer Points:" + computerPoints);
    if (yourPoints === 5) {
        gamePlays = false;
        alert("Congratulations, you win the Game!");
    } else if (computerPoints === 5) {
        gamePlays = false;
        console.log("Nice try, but Computer wins you!")
    } else {
        gamePlays = true;
    };

#2

I even understand your code, but here you go:

var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
	computerChoice = "rock";
} else if(computerChoice <= 0.67) {
	computerChoice = "paper";
} else {
	computerChoice = "scissors";
} 

var compare = function(choice1, choice2){
    if (choice1 === choice2){
        console.log ("The result is a tie!");
    }
    else if (choice1 === "Rock"){
        if (choice2 === "Scissors"){
            return "Rock wins!";
        }
    }
    else if (choice1 === "Paper"){
        if (choice2 === "Rock"){
            return "Paper wins!";
        }
    }
    else if (choice1 === "Scissors"){
        if (choice2 === "Paper"){
            return "Scissors wins!";
        }
    }
}

console.log("You: " + userChoice);
console.log("Computer: " + computerChoice);

#3

Thank you for reply but i know already that part of (easy) code. I just used some more extend in my code to make it more beautiful but something is wrong with it, can't be run.


#4

Seems like this loop:

while (gamePlays) {

misses its closing }