Computer Choice part 2


#1

so the code i used is kind of different from the one I saw in the comment in the next one.
var computerChoice = Math.random()
if (0>=computerChoice<=0.33 )
console.log("rock")
else if(0.34>=computerChoice<=0.66)
console.log("paper")
else(0.67>=computerChoice<=1)
console.log("scissors")
The above code is the one I used and it worked for me. Is it a correct code.
P.S it worked but I am thinking it's not correct


#2

@preciouglas12,
Your code should have been

if ( 0 <= computerChoice  && computerChoice <= 0.33 ) {
   console.log("rock")
}
// what happens to the VALUE's 0.3300001 until 0.3399999
else if( 0.34 <= computerChoice> && computerChoice <= 0.66) {
   console.log("paper")
}
else { //takes NO condition
   console.log("scissors")
}

===================================

The purpose of the IF ELSE-IF ELSE statement structure
is to re-assign the computerChoice variable
from a number Value into a string Value

So instead of your console.log()
you should be using something
like
computerChoice = "scissors";


#3

Thanks I now understand.