Computer Choice Part 2, In-between .34-.66


Ok folks, I've seen a few threads about this but nobody has answered my question so I'm making my own thread. Here is my code.

var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice <= .33) {
} else if (computerChoice .34 < .66) {
} else
{ computerChoice="Paper";
OKAY, this gives a syntax error : unexpected number

Now, if i replace the else if with this :
else if (computerChoice <= .66) {

That works, and that is what other people have done to pass the syntax. BUT! That would put choices 1 and 2 into the same category(0 - .66. In order to have truly fair and accurate results, wouldn't you have to do something like is in my original code? How can i code this?!


It is already greater than 0.33 or we would not be in this conditional, so,

else if (computerChoice < 0.66) {

is all we need.


heh, thanks. Guess i skipped that step in my thought process. Thanks for the clarification