4/9 Rock, Paper, Scissors Help


#1

Here is my code:

var userChoice = prompt=("Do you choose rock, paper or scissors?");
var computerChoice = Math.random(0,1)

if (computerChoice < 0.33) {
console.log(computerChoice("The computer has chosen rock!"));

} else if (computerChoice >= 0.34 && computerChoice <= 0.66) {
console.log(computerChoice("The computer has chosen paper!"));

} else (computerChoice > 0.66) {
console.log(computerChoice("The computer has chosen scissors!"));
}
console.log(computerChoice);

The error I receive is:

SyntaxError: Unexpected token '{'. Parse error.

Please show me where I went wrong!


#2

Well, you did this in a REALLY complicated way. I'm just telling you right now that all you have to do is change these:

to just:

computerChoice = "rock"

Soon, it will get to complicated to write that over and over again, so I would encourage you to just do it this way. How is it possible?

You can do:

console.log(computerChoice);

Right after your user prompt, and it will log on the console the randomized rock, paper, or scissors it has chosen.

Also, in:

Math.random isn't a function, so there isn't any parameters. So, all you have to do is:

var computerChoice = Math.random()

Your brackets seem fine, but there may be a problem. Please first make your code simpler and easier, for it will get harder on the next levels.


#3

It is a function but it still doesn't need parameters.
Also no conditions after else:

else (computerChoice > 0.66) {

#4

I wrote my code like this and I get syntax error, where am I going wrong? thank you in advance...

var userChoice = prompt("Do you choose rock, paper or scissors?");
console.log(userChoice);
var computerChoice = Math.random()
if (computerChoice) <.33
{
computerChoice === "rock";
}
else if (computerChoice) <.66
{
computerChoice === "paper";
}
else {
(computerChoice) === ("scissors");
}
console.log(computerChoice);


#5

Hope it helps

if (computerChoice <= 0.33 && computerChoice >= 0) {
computerChoice = "rock";
} else if (computerChoice >= 0.34 && computerChoice <= 0.66) {
computerChoice = "paper";
} else
{
computerChoice = "scissors";
}