Rock, Paper, Scissors problem


#1

var User1 = prompt("User1: Rock, Paper or Scissors?");

console.log(User1);

var User2 = Math.random();

if (User2 < 0.34) {

User2 = "Rock"

}

else {

if (User2 < 0.67) {
 User2 = "Paper"
}

else {
  User2 = "Scissors"  
}

}

console.log(User2);

// The following part is somehow not working!

if (User1 === User2) {
console.log("A tie!");
}

else if (User1 = "Rock") {

if (User2 = "Scissors") {
    console.log("User1 won!");
}

else {
    console.log("User2 won!");
}

}

else if (User1 = "Paper") {

if (User2 = "Scissors") {
    console.log("User2 won!")
}
else {
    console.log("User1 won!")
}

}

else {
if (User2 = "Paper") {
console.log("User1 won!")
}
else {
console.log("User2 won!")
}
};

So, whenever User2 aka the PC wins, the output still says it is User1 who won.What could be wrong?


#2

OK, I figured it out! I should use "else if (User1 === "Paper") {}" instead of "else if (User1 = "Paper") {}"