Eleccion1 es igual a piedra


#1

Este es mi link:
https://www.codecademy.com/es/courses/javascript-beginner-es-ETSkG/1/2?curriculum_id=50d3cc1bca413c863600126d#

var usuarioElige = prompt("¿piedra, papel o tijera?")
var computadorElige = Math.random()
if (computadorElige <=0.33){
console.log("piedra")
}else if(computadorElige <=0.67){
console.log("papel")
}else{
console.log("tijera")
}

var comparar = function (eleccion1,eleccion2){
if (eleccion1 === eleccion2){
return("¡Es un empate!")
} if(eleccion1 === computadorElige <=0.33){
console.log("Papel gana")
}if(eleccion2 === computadorElige <=0.67){
console.log("Tijeras ganan")
} else {
console.log("Piedra gana")}}

Me da este error:¡Uy! Probá otra vez. La sentencia no da como resultado un ganador


#2

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.


and then you will have to create.....

Please read
http://www.codecademy.com/forum_questions/559dcb4be39efe550f00006b
and concentrate on:

  • the creation of the compare function
  • the truth-table
  • the build of the IF ELSE-IF statement structure as part of the compare FUNCTION-BODY
  • the execution of the compare function (keeping in mind that the return statement is used )
    //==========================================//