4.Computer choice:Part 2


I am not able to get a solution for my problem, i have visited other links but couldn't find the best answer suited for my problem.

This is my code:

var userChoice =prompt("Do you choose rock, paper or scissor?);

var computerChoice = Math.random();


if (computerChoice <= 0.33) {
else if (computerChoice > 0.34 && computerChoice<=0.66) {
else {


Error: Syntax error, Invalid or unexpected token.

I would be glad if you anyone could help me.


you need a semi colon instead of a :


You have to close string in the prompt (add " at the end of the string):

var userChoice =prompt("Do you choose rock, paper or scissor?);

And there is a colon at the end of this line:


I guess that you meant to use a semicolon.

Your code does not have now any syntax errors. You should read again instructions and make sure that your code completely implements them.


1/ You didn't close your string in your prompt.
2/ You have a colon after console.log("rock"): //<==Here! change that to a semi colon.
3/ Doesn't the instructions tell you to equate computerChoice to "rock" or "paper" or "scissors" based on your conditions?

//for example
else if (computerChoice > 0.34 && computerChoice<=0.66) {
    computerChoice = "paper";


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

This worked for me now.


and arent we supposed to use "console.log" command for printing rather than "computer choice=paper"

I dont know the difference and i think console.log is only what i have come across in these chapters.

Sorry if i am wrong


You'll need to compare computerChoice with your input in the next few steps. Hence why they asked you to equate your computerChoice rather than log it. But if this works, it works. Good job :slight_smile:

The "rock", "paper" and"scissors" will still show when you have something like "computer choice=paper" because you already have console.log(computerChoice); before your if statements. So why type console.log again?


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