What is choice 1 is scissors?


#1

Hey guys, i seem to get a load of erros on this although i went past the first 2 with ease here is my code

var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
	computerChoice = "rock";
} else if(computerChoice <= 0.67) {
	computerChoice = "paper";
} else {
	computerChoice = "scissors";
} console.log("Computer: " + computerChoice);
var compare = function(choice1, choice2) {
if (choice1 === choice2) {
return "The result is a tie!";
}
else if (choice1 === "rock") { if (choice2 === "scissors"){return "rock wins";
}
else {return "paper wins";}
}
else if(choice1 ==="paper"){
if (choice2 ==="rock") {
    return "paper wins";
}
else {
    return "scissors wins";
  }
}
if (choice1 === "scissors") { if (choice2 === "rock"){return "rock wins";
}
else if (choice1 === "scissors") {
  if (choice2 === "paper") {return "scissors wins";
  } 
  else {return "scissors wins";
  }
}

Im very nice to JavaScript so dont cringe if you see any very bad mistakes and thanks


#2

Maybe try to format the code (jsbeautifier.org or just add an indentation level whenever you enter a block of code {}) that would make it much easier to read. The quoted code above seems to be the problem have a look at how you did it for the other else ifs.