Why did this work (Computer Choice Part 2 answer)?


Hey, everyone. I just completed "Computer Choice Part 2" and I got it correct but I want to know if it was an error. I'm asking because I have noticed that sometimes the right answers are flagged as wrong. Now I fear the wrong answers may be accepted as correct (what a way to live). Was my initial code correct (specifically referring to the "else if" statement)? Is the syntax off?

var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice <= 0.33) {
else if (0.34<= computerChoice <= 0.66) {
else {


The following line:

else if (0.34<= computerChoice <= 0.66) {

is wrong. Read here for why it is wrong.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.