Computer Choice: Part 2


#1

So I looked on the other pages for help but I couldn't improve my program that much. I still get "There is something wrong with your syntax."


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


#2

if{ 
(computerChoice <=.33) 
 { 
return "rock" 
 }

Alright let's run through how "If" statements work again just to see what's going on here.

if ( condition <= .33 ) {
  //Code here!
}

The only issue you have is that you have an extra opening bracket " { " at the beginning of your if statement.

if { //This syntax is incorrect!

#3

Here's the syntax that worked for me... Hope it helps :smile:

Just a question.
If the number 0.0855387260671705 is a computers answer, why did it write "paper"?
BTW my answer was "rock"...