Not sure what I did wrong

Here’s the 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 win”;
}
}
else if (choice1 === “scissors”){
if (choice2 === “paper”){
return “scissors win”;
}
else
{
return “rock wins”;
}
}
};

Hi remove the coment here by removing the /* */

/*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);*/

And then call you compare function,

what’s wrong in my code??? it’s for exercise 9/9 for “rock, paper , scissors”

else if (! choix1 === “papier”, “ciseaux”, “pierre”) {
if (Choix2 === “papier”, “ciseaux”, “pierre”!) {
return “s’il vous plaît choisir une option”;
}
else {
return “vous choisissez rien”;
}
}
};

console.log (comparer (choixUtilisateur, choixOrdi));

Hi this part

else if (! choix1 === "papier", "ciseaux", "pierre")
if (Choix2 === "papier", "ciseaux", "pierre"!) 

What do you want to do?

i want to finish the part build "rock, paper, scissors btu the final exercis i don’t understand,

this my code and for exercice 9 i don’t understand what is th answeer ?

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 gagnent"
}}

else if (choix1 === “ciseaux”) {
if (choix2 ===“pierre”) {
return “pierre gagne”
}
else {
return “ciseaux gagne”
}
}
}
console.log(“choixUtilisateur; choixOrdi”);

This part you want to call the function compare instead of

console.log("choixUtilisateur; choixOrdi");

Change it like that

comparer(choixUtilisateur, choixOrdi)

He send me yes we did but is also send comapre is not definied why ???

Sorry its from the English versione try it like that

comparer(choixUtilisateur, choixOrdi)

it’s right now thx bro

1 Like