Help please - i miss something in my code


#1



what do i do wrong???


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

    if (computerChoice <= 0.33){
        computerChoice = "rock"
    }
    else if (computerChoice <= 0.66){
             computerChoice "paper"
    }
    else (computerChoice <= 1) {
         computerChoice "scissors"
    }


#2

You're missing a few equal marks.


#3

i changed it and its still gives me error with syntax

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

    if (computerChoice <= 0.33){
        computerChoice = "rock";
    }
    else if (computerChoice <= 0.66){
             computerChoice ="paper";
    }
    else (computerChoice <= 1) {
         computerChoice = "scissors";
    }
    console.log (computerChoice);

#4

There should not be a space between the g and (


#5

i actually solved it, i removed the(computerChoice <= 1) from the else line.
i dont really understand why it works but it did.
```
var userChoice = prompt("Do you choose rock, paper or scissors?");
console.log(userChoice);
var computerChoice = Math.random();

if (computerChoice <= 0.33){
    computerChoice = "rock";
}
else if (computerChoice <= 0.66){
         computerChoice = "paper";
}
else{
     computerChoice = "scissors";
}
console.log (computerChoice);

`


#6

It worked because it isn't an else if statement, so it isn't asking for a condition.
Sorry for overlooking that


#7

so u shouldn't use a condition on an else statement ?


#8

Nope, that's just for if and else if statements


#9

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