SyntaxError: missing before statement


#1



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


#2

else is not allowed to have a condition

do like

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


#3

I tried it worked . but user choice and computers choices appear same .


#4

it should be because you dont need to console

you have to do like this

if(computerChoice<=0.33){
computerChoice="rock"
}


#5

yes!! now I got it . But i think console.log should spit the value ... isn't it strange?


#6

sorry! what do you want to say?


#7

when i used console.log instead of computerChoice="rock" I got user and computer choice same i.e both are rock .. just I changed console.log to computerChoice="rock" as you said , it displayed user as rock and computer as scissors ... So that seems strange because we are just using console to display the value that's in computerChoice.


#8

it cant be print "rock" all the time.it'll print value according to Math.random()
when you are using console.log("rock") thats mean it'll just display "rock" if you use console.log("you")
it'll just print "you" not your name :slight_smile:

is everything fine now?