Can you help me please? How can I fix this?


I am stuck at building rock, paper, scissors on part 8.
how can I fix it?

it says "Your code returned 'scissors wins' instead of 'undefined' when the inputs are scissors and rock"

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)
{ return "The result is a tie!" }
else if(choice1=== "rock")
{return "rock wins"}
{return "paper wins"}}
 else if(choice1==="paper")
 { if(choice2==="rock")
 return "paper wins"}
 { return "scissors wins"}
 { if(choice2==="rock")
 {return "rock wins"}
 { return "scissors wins"}}}
 compare(userChoice, computerChoice)


if/else syntax

if (condition) {
   //your code
else {
    //your code

You can see else does not have any conditions associated with it.

Youre writing like this.
wrong syntax

if (condition1) {
   //your code
else (condition2){
    //your code

which is wrong.
Fix this part,there is one more error to fix.
do reply what you get ?


okay, I fixed that part. Thanks.

what is the other mistake? It still says " Your code returned 'scissors wins' instead of 'undefined' when the inputs are scissors and rock".


You missed curly brackets in last else if statement.
Your if/else is inside else if ? so you need to do like this..

else if (condition) {
    if(condition) {
       //your code
    } else {
       //your code


oh, thank you. I fixed it.


cheers! good work! :thumbsup: :slight_smile:


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