4.computer choice: part2 what's wrong with my code?


#1


https://www.codecademy.com/courses/javascript-beginner-en-Bthev-mskY8/0/4?curriculum_id=506324b3a7dffd00020bf661#


"Oops, try again. There was a problem with your syntax."


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

    if 0 < computerChoice && computerChoice < =1/3  {
        computerChoice="rock";
    }
    else if 1/3 < computerChoice && computerChoice < 2/3 {
        computerChoice="paper";
    }
    else {
        computerChoice="scissors";
    }
    
console.log(computerChoice);


#2

try this code

var userChoice = prompt("Do You rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice<=0.33)
{
    computerChoice = "rock";
}
else if (computerChoice>0.33 && computerChoice<=0.66)
{
    computerChoice = "paper";
}
else
{
    computerChoice = "scissors";
}

console.log(computerChoice);

#3

thanks a lot ! it works! :slight_smile:


#4

Glad I could help :slight_smile:


#5

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