Need help with rock paper scissors


I'm having trouble with this code. Trying to make a rock paper scissor game but it says i have an unexpected token "else". Not sure where the problem is, it was running fine until i added the last part of the code (the last else if) My code is in french since I speak both english and french. So both languages work

var choixUtilisateur = prompt("Choisissez-vous pierre, feuille, ou ciseaux ?");
var choixOrdi = Math.random();
if (choixOrdi < 0.34) {
choixOrdi = "pierre";
} else if(choixOrdi <= 0.67) {
choixOrdi = "feuille";
} else {
choixOrdi = "ciseaux";
} console.log("Ordinateur : " + choixOrdi);

var comparer = function(choix1, choix2){
if(choix1 === choix2){
return "Egalité !";
else if(choix1 === "pierre"){
if(choix2 === "ciseaux"){
return "pierre gagne !";
else {
return "feuille gagne !";

else if(choix1 === "feuille"){
if(choix2 === "pierre"){
return "feuille gagne !";
else {
return "ciseaux gagne";
else if(choix1 === "ciseaux"){
if(choix2 === "feuille"){
return "ciseaux gagne !";
return "pierre gagne";




@ochotk it looks like you just need to rearrange your code. The else if statements should come before the else statement, and you should only have one else statement at the end (unless they are nested within the else if statements). The else is like a catch-all at the end, so you want all of the ifs and else ifs in front of it.