version 1
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
let hum = prompt('Выберите "камень", "ножницы" или "бумага"');
|
||||
let npc = Math.floor(Math.random() * 3) + 1;
|
||||
|
||||
console.log(npc);
|
||||
console.log(hum);
|
||||
|
||||
const Stone = { num: 3, Name: 'камень' };
|
||||
const Scissors = { num: 2, Name: 'ножницы' };
|
||||
const Paper = { num: 1, Name: 'бумага' };
|
||||
|
||||
|
||||
if (hum === Stone.Name) {
|
||||
hum = Stone.num;
|
||||
} else if (hum === Scissors.Name) {
|
||||
hum = Scissors.num;
|
||||
} else if (hum === Paper.Name) {
|
||||
hum = Paper.num;
|
||||
};
|
||||
|
||||
|
||||
if (npc === 1 && hum === 3) {
|
||||
npc = 4
|
||||
}
|
||||
if (npc === 3 && hum === 1) {
|
||||
hum = 4
|
||||
}
|
||||
|
||||
if (npc > hum) {
|
||||
console.log("Вы проиграли");
|
||||
alert("Вы проиграли");
|
||||
} else if (npc === hum) {
|
||||
console.log("Ничья");
|
||||
alert("Ничья");
|
||||
} else if (npc < hum) {
|
||||
console.log("Вы выиграли");
|
||||
alert("Вы выиграли");
|
||||
} else {
|
||||
console.log("Пользователь написал какую-то фигню");
|
||||
}
|
||||
Reference in New Issue
Block a user