<!DOCTYPE html>
<html>
<head>
<title>じゃんけんゲーム</title>
</head>
<body>
<h2>じゃんけんゲーム</h2>
<button onclick=”janken(‘グー’)”>グー</button>
<button onclick=”janken(‘チョキ’)”>チョキ</button>
<button onclick=”janken(‘パー’)”>パー</button>
<div id=”result”></div>

<script>
function janken(playerChoice) {
const choices = [‘グー’, ‘チョキ’, ‘パー’];
const computerChoice = choices[Math.floor(Math.random() * 3)];
const result = determineWinner(playerChoice, computerChoice);
document.getElementById(‘result’).innerHTML = `あなたの選択: ${playerChoice}<br>コンピューターの選択: ${computerChoice}<br>${result}`;
}

function determineWinner(player, computer) {
if (player === computer) {
return ‘引き分けです!’;
}
if ((player === ‘グー’ && computer === ‘チョキ’) ||
(player === ‘チョキ’ && computer === ‘パー’) ||
(player === ‘パー’ && computer === ‘グー’)) {
return ‘あなたの勝ちです!’;
}
return ‘あなたの負けです…’;
}
</script>
</body>
</html>