Skip to content

Instantly share code, notes, and snippets.

@PascalR2014
Created December 25, 2015 23:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PascalR2014/f1c3df9a43fa519f2a1a to your computer and use it in GitHub Desktop.
Save PascalR2014/f1c3df9a43fa519f2a1a to your computer and use it in GitHub Desktop.
Games in javascript, for correction please !
/*
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);
}*/
// <--Cas d'égalité + var comparer--
var comparer = function(choix1, choix2) {
if(choix1 === choix2) {
return ("Egalité !");
}
// <--1-choix la pierre vs les ciseaux--
if (choix1 === "pierre"){
}
else(choix2 === "ciseaux"){
return ("pierre gagne !");
}
// <--1b-choix les ciseaux vs la pierre--
if (choix1 === "ciseaux"){
}
else(choix2 === "pierre"){
return ("pierre gagne !");
}
// <--2-choix la feuille vs la pierre --
if (choix1 === "feuille"){
}
else(choix2 === "pierre"){
return ("feuille gagne !");
}
// <--2b-choix la pierre vs la feuille --
if (choix1 === "pierre"){
}
else(choix2 === "feuille"){
return ("feuille gagne !");
}
// <--3-choix les ciseaux vs la pierre--
if (choix1 === "ciseaux"){
}
else(choix2 === "pierre"){
return ("pierre gagne !");
}
// <--3b-choix la pierre vs les ciseaux--
if (choix1 === "pierre"){
}
else(choix2 === "ciseaux"){
return ("pierre gagne !");
}
// --4-choix les ciseaux vs la feuille--
if (choix1 === "ciseaux"){
}
else(choix2 === "feuille"){
return ("ciseaux gagnent !");
}
// --4b-choix la feuille vs les ciseaux --
if (choix1 === "feuille"){
}
else(choix2 === "ciseaux"){
return ("ciseaux gagnent !");
}
}
//;
//<--Fin du code !--
//<-- Query result: SyntaxError: missing before statement
@PascalR2014
Copy link
Author

Please give me a correct code for this game !
Stone, Sheet(Leaf), scissors
Thanks a lot for your time !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment