Only logging computer: computerChoice help!


#1

i have the code console.log the results, confirm the results, and return the results(don't worry the return is under the console.log and confirm) for every outcome, but all it says is compute:r scissors, or basically only what the computer chose. it does not say what i chose, or who won, if it was a tie, and it certainly does not do what i told it to do for a outcome. what is wrong!!??? no one will help me please help me. here is my code:

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";
} console.log( "computer: " + computerChoice );
confirm("The Computer chose " + computerChoice + ", and you chose " + userChoice + ", good game!");
var compare = function(userChoice, computerChoice){
if( userChoice === computerChoice){
console.log("Tie, try again!")
confirm("Tie, try again!")
return "The result is a tie!";
}
else if(userChoice === "Rock") {

    if(computerChoice === "Scissors"){
                      console.log("The computer chose Scissors, and you chose Rock, so you win!")
        confirm("The computer chose Scissors, and you chose Rock, so you win!")
        return "The computer chose Scissors, and you chose Rock, so you win!";
        }
        else {
                           console.log("The computer chose Paper, and you chose Rock, so you lose!")
confirm("The computer chose Paper, and you chose Rock, so you lose!")
return "The computer chose Paper, and you chose Rock, so you lose!";
            }
}

else if(userChoice === "Paper") {
if(computerChoice === "Rock") {
console.log("The computer chose Rock, and you chose Paper, so you Win!")
confirm("The computer chose Rock, and you chose Paper, so you Win!")
return "The computer chose Rock, and you chose Paper, so you Win!";
} else {
console.log("The computer chose Scissors, and you chose Paper, so you Lose!")
confirm("The computer chose Scissors, and you chose Paper, so you Lose!")
return "The computer chose Scissors, and you chose Paper, so you Lose!";
}
}
else if(userChoice === "Scissors") {
if(computerChoice === "Rock") {
console.log("The computer chose Rock, and you chose Scissors, so you lose!")
confirm("The computer chose Rock, and you chose Scissors, so you lose!")
return "The computer chose Rock, and you chose Scissors, so you lose!";
}
else {
console.log("The computer chose Paper, and you chose Scissors, so you win!")
confirm("The computer chose Paper, and you chose Scissors, so you win!")
return "The computer chose Paper, and you chose Scissors, so you win!";
}
} }

// and i tried erasing the ' console.log( "computer: " + computerChoice ); ' but it still will not work please, please help!


#2

here's my code, maybe you can figure out where you went wrong:

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";
} console.log("Computer: " + computerChoice);
var compare = function(choice1, choice2){
if (choice1 === choice2){
return "The result is a tie!";
}
else if (choice1 === "rock") {
if (choice2 === "scissors") {
return "rock wins";

}
   else {
       return "paper wins";

}
}
else if (choice1 === "paper")
{ 
    if (choice2 === "rock"){
        return "paper wins";
    }
    else {
        return "scissors wins";
    }
}
else if (choice1 === "scissors")
{
    if( choice2 === "rock") {
        return "rock wins"
    }
    else {
        return "scissors wins";
    }

}
};
console.log(compare(userChoice, computerChoice));
console.log(userChoice, computerChoice);


#3

I see you are missing this at the end:

};
console.log(compare(userChoice, computerChoice));
console.log(userChoice, computerChoice);

notice the semicolon at the end of last bracket.


#4

THANK YOU SOOOO MUCH!!!!!! i have been stuck on this forever, and i know, i suck at code, but thanks so much for helping it means a lot!