コードの最後にあるボタンとジャンケンでゲームを作成しましたが、一度クリックすると消えてしまい、そのコードを何度も繰り返し続けるのは意味がありません。
function game(){
var userChoice= prompt("Do you choose rock, paper, or scissors?");
document.write("You chose " + userChoice + ". <br/>")
var computerChoice= Math.random();
if(computerChoice<=0.33){
computerChoice="rock";
}
else if(computerChoice<=0.67){
computerChoice="paper";
}
else{
computerChoice="scissors";
}
document.write("The computer chose " + computerChoice + ". <br/>");
if(userChoice==computerChoice){
document.write("TIE!!!!");
}
else if(userChoice=="paper" && computerChoice=="rock"){
document.write('<span style="color:red">You win!</span>');
}
else if(userChoice=="rock" && computerChoice=="scissors"){
document.write('<span style="color:red">You win!</span>');
}
else if(userChoice=="scissors" && computerChoice=="paper"){
document.write('<span style="color:red">You win!</span>');
}
else if(userChoice=="scissors" && computerChoice=="rock"){
document.write('Sorry, you lose.');
}
else if(userChoice=="rock" && computerChoice=="paper"){
document.write("Sorry, you lose.");
}
else if(userChoice=="paper" && computerChoice=="scissors"){
document.write("Sorry, you lose.");
}
else if(userChoice=="Chuck Norris"){
document.write("This program bows down to your superiority, YOU WIN!!!!");
}
document.write('<button type="button" style="display:block;" onclick="game()">Play Again!</button>');
}
<body onload="game()">