3. Math.Random HELP


Replace this line with your code.


var userChoice = prompt("Do you want rock paper or scissors?")
var computarChoice = Math.random();


what goes in the parentheses


Nothing goes in the parentheses.


then why wont it work





Have a close look at


required is computerChoice



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.


Thank you so much you really will help me.... but for number 4. and I'm stuck on three, I don't know what it means by, "Did you remember to log computerCoice tothe console
and thanks again for helping me with my misspelling, that would have taken me forever to find.


var userChoice = prompt("Do you want rock paper or scissors?")
var computarChoice = Math.random();

What goes in console.log and Math.random




var computerChoice = Math.random();

you have created a so-called variable computerChoice
and with a = sign you are assigning a **number Value to this computerChoice variable.
This number Value is the =result= of calling the Math.random() Method.
( in Javascript the Math.random() Method does NOT take any argument's )

The console.log() method will Display any argument you give it.
like for instance the computerChoice variable

console.log( computerChoice );


Thank you so much, my computer was deleting my coding? strange Thanks again!:grinning:


and thanks for your previous post too! :grin:


computER not computAR :slight_smile: