I'm a beginner in programming and I discovered a web site to start such codeacademy, but they have some errors and tals making it difficult to understand.
I'm in the following javascript exercise:
Computer Choice: Part 2 We have computerChoice, but it is now equal to a random number between 0 and 1. We need some way translate this random number into a choice between stone, paper and scissors. How will we do this?!
If computerChoice is between 0 and 0.33, make computerChoice equal to "stone". If computerChoice is between 0.34 and 0.66, computerChoice equal to "paper". If computerChoice is between 0.67 and 1, make computerChoice equal to "scissors". But there are three results! If / else allows only two results. And now?! We need to use if / else if / else. Read the tip for the complete syntax. You go find grace so easy it is.
Instructions Under your existing code, write the if / else statement if / else In the respective code blocks, change the value of computerChoice based on the rules above. Remember, you do NOT need use var when you are changing the value of an existing variable.
Detail: They did not teach me how to if else
together.
I have to play a little game of stone, paper and scissors by following these instructions.
Here's how I wrote the code:
var userChoice = prompt("Você escolhe pedra, papel ou tesoura?");
var computerChoice = Math.random();
console.log (computerChoice);
if (computerChoice <= 0.33) {
console.log("Pedra");
} else if (computerChoice Não sei o que colocar aqui (tem alguma função "entre") {
console.log("Papel");
} else (computerChoice > 0.67) {
console.log("Tesoura");
}
If you can help me to advance the course!