Created
June 23, 2016 21:24
-
-
Save mihailsitnic/a31b8abefad9861677ef0e33c2165b9e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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