The system thinks this code works, but it doesn't


#1


https://www.codecademy.com/courses/javascript-beginner-en-Bthev-mskY8/0/4?curriculum_id=506324b3a7dffd00020bf661#

Way to go!


Replace this line with your code. Do not remove the backticks.
userChoice = prompt("Do you choose paper scissors or stone?")
var computerChoice = Math.random()
console.log(computerChoice)
computerChoiceTranslation = function()
{
    if(computerChoice < 0.34)
    {
        return "rock";
    }
    else
    {
        if(computerChoice > 0.33);
    {
        if (computerChoice < 0.67);
        {
            return "paper";
        }
    }
    }
     
    {
        if(computerChoice <= 0.67 >= 1)
         {
             return "scissors";
         }
    }
}
computerChoice = computerChoiceTranslation
console.log(computerChoice())


#2

@chipsurfer68121,

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.


#3

@chipsurfer68121,
If you have corrected the IF ELSE-IF ELSE statement structure
and updated the corresponding condition's
in your computerChoiceTranslation() function.....

you could make use of this computerChoiceTranslation() function
by calling the function
like

computerChoice = computerChoiceTranslation();

I would have included the Math.random() call within the above mentioned function

Reference

google search
== the Book ==
javascript [your question] site:developer.mozilla.org

== discussions / opinions ==
javascript [your question] site:stackoverflow.com

== guidance ==
www.crockford.com
http://javascript.crockford.com/code.html <---JavaScript code-convention
http://javascript.crockford.com/survey.html
https://developer.mozilla.org/en-US/docs/Web/JavaScript/A_re-introduction_to_JavaScript
www.developer.mozilla.org/en-US/docs/Web/JavaScript/Guide


#4

I know, but it thinks the code is right!