What am I doing wrong?


#1

// 1 - Rock, 2 - Scissors, 3 - Paper



var userChoise  = prompt("Do you choose rock, paper or scissors?");

var computerCh = Math.floor(Math.random() * (3 - 1+ 1)) + 1;

if (userChoise  == 2 && userCh == 1) {
    console.log("User Win!");
}
else if (userChoise == 3 && userCh == 2) {
    console.log("User Win!");
}
else if (userChoise == 1 && userCh == 3) {
    console.log("User Win!");
}
else if (userChoise  == userCh) {
    console.log("Try Again!");
}
else {
    console.log("PC Win!");
}
console.log(computerCh);


// Oops, try again. Did you declare a variable called userChoice?

// ReferenceError: userCh is not defined

#2

var userChoise  //Oops, try again. Did you declare a variable called userChoice?

userCh == 1  // ReferenceError: userCh is not defined

so you should declare the varible first

#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.