Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mihailsitnic/a31b8abefad9861677ef0e33c2165b9e to your computer and use it in GitHub Desktop.
Save mihailsitnic/a31b8abefad9861677ef0e33c2165b9e to your computer and use it in GitHub Desktop.
var question = prompt("Камень, ножницы или бумага?", "Камень Ножницы Бумага");
var rndnubmer = Math.random();
if (rndnubmer < 0.34) {
rndnubmer = "Камень";
}
else if (rndnubmer <= 0.67) {
rndnubmer = "Ножницы";
}
else {
rndnubmer = "Бумага";
}
console.log("Компьютер: " + rndnubmer);
var choice1 = question;
var choice2 = rndnubmer;
var complete = function(choice1, choice2) {
if (choice1 === choice2) {
return "Никто не победил!";
}
else if (choice1 === "Камень") {
if (choice2 === "Ножницы") {
return "Камень победил!"
}
else {
return "Бумага победила!";
}
}
else if (choice1 === "Бумага") {
if (choice2 === "Камень") {
return "Бумага победила!"
}
else {
return "Ножницы победили!";
}
}
else if (choice1 === "Ножницы") {
if (choice2 === "Бумага") {
return "Ножницы победили!"
}
else {
return "Камень победил!";
}
}
}
alert(complete(choice1, choice2));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment