I dont understand the error, rock, scissors, paper 7/9


#1

Why is this wrong?

else if(eleccion1 === "papel"){
if(eleccion2 === "piedra"){
return "Papel gana";
}
else{
return "tijera gana";
}
}
}


#2

Hi can you post all your code ?


#3

Can you explain why?

var usuarioElige = prompt("piedra, papel o tijera?");
var computadoraElige = Math.random();
if (computadoraElige <0.34){
computadoraElige = "piedra";
}else if(computadoraElige <=0.67){
computadoraElige = "papel";
}else{
computadoraElige = "tijera";
}

var comparar = function(eleccion1, eleccion2){
if(eleccion1 === eleccion2){
return "¬°Es un empate!";
}

else if(eleccion1 === "piedra"){
if(eleccion2 === "tijera"){
return "Piedra gana";
}
else{
return "Papel gana";
}
}
}else if(eleccion1 === "papel"){
if(eleccion2 === "piedra"){
return "Papel gana";
}
else{
return "tijera gana";
}
}
}


#4

Hi this part you have more } than you need in this case you close the compare function before

else if(eleccion1 === "piedra"){
if(eleccion2 === "tijera"){
return "Piedra gana";
}
else{
return "Papel gana";
}
}
} < == remove this one

====

This part of your code is right because all your code should be inside the compare function so at the end of your code you should have three } like you did

else if(eleccion1 === "papel"){
if(eleccion2 === "piedra"){
return "Papel gana";
}
else{
return "tijera gana";
}
}
}

#5

How do I put it inside compare funmction?


#6

Its yet inside just remove the } I show you .