Computer Choice 2


#1

What am I doing wrong?

var userChoice = prompt("Pedra, Papel ou Tesoura?");
var computerChoice = Math.random();

if (computerChoice <= 0.33) {
computerChoice === "Pedra";
}else if (computerChoice >= 0.34 || computerChoice <= 0.66) {
computerChoice === "Papel";
}else (computerChoice >= 0.67 || computerChoice <= 1) {
computerChoice === "Tesoura";
}


#2

here you should assign a value to computerChoice but this:

computerChoice === "Papel";

does compare computerChoice to "Papel". So better use computerChoice = "Papel"


#3

Yes, thanks.... but still not working

var userChoice = prompt("Pedra, Papel ou Tesoura?");
var computerChoice = Math.random();

if (computerChoice <= 0.33) {
computerChoice = "Pedra";
}else if (computerChoice >= 0.34 || computerChoice <= 0.66) {
computerChoice = "Papel";
}else (computerChoice >= 0.67 || computerChoice <= 1) {
computerChoice = "Tesoura";
}


#4

Also else has no condition. And || means OR which means that only one of the two conditions must be true so as computerChoice >= 0.34 is obviously true as you would have otherwise chosen the first case this will always pick the second case if the first is not met. So better use && (AND) instead which requires both conditions to be true.