4. Syntax Error - Unsure how to proceed


Could I have some help with this one please. I'm not sure what I've left out/put in that I shouldn't have.

Console displays "SyntaxError: Syntax error" and error message at the bottom of the screen states "Oops, try again. There was a problem with your syntax."

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

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

Also, as an additional Q - I noticed on other people's posts they have the else statement as

else (computerChoice >= 0.66 && computerChoice <= 1);

or similar. Is this actually required or could I simply leave it as else (computerChoice > 66); as my initial instinct had me doing. What would be the issue of leaving the max. number undefined when the computer only calculates between 0 and 1?


An ELSE statement does NOT take a condition !!!

The Math.random() method will deliver a number with a value
in the range of 0_(included)_ upontill 0.9999_(1 excluded)_.

As you will have to divide the number range form 0_(inclusive)_ to 0,9999_(so 1 excluded)_
into 3 equal partitions
we have to use an if else-if else statement.
The if else-if else skeleton looks like:

    if (conditionA) {
               //conditionA is true
                //your code 
     } else if (conditionB) {
               //conditionA is false
               //conditionB is true
              //your code 
    } else {     // <=== !! Takes NO condition-statements !!
               //conditionA is false
               //conditionB is false
              //your code 

following the Instructions the conditions would be:

  1. If computerChoice is between 0 and 0.33, make computerChoice equal to "rock".
    ( 0 <= computerChoice && computerChoice <= 0.33) which we capture at the IF using
    ( computerChoice <= 0.33)

  2. If computerChoice is between 0.34 and 0.66, make computerChoice equal to "paper".
    ( 0.33 < computerChoice && computerChoice < 0.67) which we capture at the ELSE IF as
    ( computerChoice < 0.67 )

  3. If computerChoice is between 0.67 and 1, make computerChoice equal to "scissors".
    ( 0.67 <= computerChoice && computerChoice < 1) , you reached the ELSE level
    you can asume that computerChoice is greater equal to 0.67,
    the ELSE does NOT take a condition, just write your code.


Thanks, Leonhard.

I know you've replied the same on other people's posts but for some reason I couldn't understand what you are explaining to them. This makes sense now. I'm sure it will work when I'm able to try it on a PC.


If you don't understand.....
If you get stuck...
Try to rephrase in your words....and then see were you get stuck
and post the question , with the code you have.....