3. Math.Random HELP


#1



Replace this line with your code.


#2

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


#3

what goes in the parentheses


#4

Nothing goes in the parentheses.


#5

then why wont it work


#6

SO ANNOYING
PLEASE HELP ANYBODY
-Heammawihio


#7

@heammawihio,

Have a close look at

computarChoice

required is computerChoice

#8

@heammawihio,

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.


#9

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.


#10

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

What goes in console.log and Math.random


#11

@heammawihio,

With

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 )
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random

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

console.log( computerChoice );

#12

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


#13

and thanks for your previous post too! :grin:


#14

computER not computAR :slight_smile: