Prompt Error


#1
var myChoice = prompt('Pedra, Papel ou Tesoura?');
              
var computerChoice = Math.random();

function escolha() {
  
   if (computerChoice < 0.33) {
    computerChoice = 'Pedra'
  } else if (computerChoice > 0.66) {
    computerChoice = 'Tesoura'
  } else  {
    computerChoice = 'Papel'
  }
}

escolha();

function Compare() {
  if (myChoice === computerChoice) {
    console.log('EMPATE!');
  } else if (myChoice === 'Tesoura' && computerChoice === 'Papel') {
    console.log('Você ganhou!');
  } else if (myChoice === 'Tesoura' && computerChoice === 'Pedra') {
    console.log("Ganhei haha!");
  } else if (myChoice === 'Pedra' && computerChoice === 'Papel') {
    console.log('Ganhei haha!');
  } else if (myChoice === 'Pedra' && computerChoice === 'Tesoura') {
    console.log('Você ganhou!');
  } else if (myChoice === 'Papel' && computerChoice === 'Tesoura') {
    console.log("Ganhei haha!"); 
  } else if (myChoice === 'Papel' && computerChoice === 'Pedra') {
    console.log("Você ganhou!");
  }
}

console.log('escolha do Usuário: ' + myChoice)
console.log('Escolha do PC: ' + computerChoice)
Compare()


Why am I having trouble with the variable myChoice?


#2

I don’t understand your question on my console it works fine
Does it output a error?


#3

how do you test on your console? the only way I make the code run is in the exercise console itself, how can I test on an external console? sorry my english, I am brazilian


#4

Eu posso falar português!
Eu uso o console debugger que tem no chrome é só apertar F12


#5

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