Illegal Return Statement, Computer Choice Part 2


I have tried this many time and I have no idea what is wrong Please help.

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


No semicolons aftercondition:

Also have a look at this to learn how to make your code readable:

PS: And of course no return! Return is a keyword that is only allowed to be used in functions, instead change the value of computerChoice to for example "rock".


Hi instead of return "rock" put computerChoice == "rock" and the same for paper and so its should be like that

  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){
        computer == "paper"}
    else {
        computerChoice == "scissors"}

in this case you don't need aelse if statement


Thank you I tried that and now the statement is not illegal, but it does not understand "else".


That is because of the semicolon see the link mentioned above.