Rock paper scissors program only runs once

So once i open my container in chrome the dialog box comes up and everything works fine but the problem is that I don’t know how to make the program run constantly. I have a scoreboard for who wins but how do I get the prompt box to come back again or repeat all of the code?

Here is my code:

console.log("hi");
var userChoice = prompt("take your pick(1, 2 or 3): \n 1.Rock \n 2.Paper \n 3.Scissors");
var userScore = 0;
var computerScore = 0;
const userScore_span = document.getElementById("user-score");
const computerScore_span = document.getElementById("computer-score");
const scoreBoard_div = document.querySelector(".score-board");

function win(user, computer) {
  userScore = userScore + 1;
  userScore_span.innerHTML = userScore;
  computerScore_span.innerHTML = computerScore;
  console.log(user);
  console.log(computer);
  console.log(win);
}

function lose(user, computer) {
  computerScore = computerScore + 1;
  userScore_span.innerHTML = userScore;
  computerScore_span.innerHTML = computerScore;
  console.log(user);
  console.log(computer);
  console.log(lose);
} {
  if (userChoice == 1) {
    userChoice = "Rock";
  } else if (userChoice == 2) {
    userChoice = "Paper";
  } else if (userChoice == 3) {
    userChoice = "Scissors";
  } else {
    alert("Error, press F5");
  }


  alert("You choose: " + userChoice);

  console.log(userChoice);

  //computer choice
  var computerChoice = Math.random();
  if (computerChoice < 0.33) {
    computerChoice = "Rock"
  } else if (computerChoice < 0.66) {
    computerChoice = "Paper";
  } else {
    computerChoice = "Scissors";


  }
  alert("Computer choose: " + computerChoice);

  console.log(computerChoice);
}

if (userChoice === "Rock" && computerChoice === "Scissors") {
  alert("Rock crushes scissors.You Win!");
  win(userChoice, computerChoice);


} else if (userChoice === "Rock" && computerChoice === "Paper") {
  alert("Paper covers rock. You lose!");
  lose(userChoice, computerChoice);

} else if (userChoice === "Paper" && computerChoice === "Rock") {
  alert("Paper covers rock. You win!");
  win(userChoice, computerChoice);



} else if (userChoice === "Paper" && computerChoice === "Scissors") {
  //scissors
  alert("Scissors cuts paper. You lose!");
  lose(userChoice, computerChoice);

} else if (userChoice === "Scissors" && computerChoice === "Rock") {
  alert("Rock crushes scissors. You lose!");
  lose(userChoice, computerChoice);

} else if (userChoice === "Scissors" && computerChoice === "Paper") {
  alert("Scissors cuts paper. You win!");
  win(userChoice, computerChoice);

} else if (userChoice == computerChoice) {
  alert("It's a tie!")
}

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.

markdown_Forums

you need to loop your code.

Put everything in a loop so that i runs again and again.
You may even add an extra promt so that it asks if user wants to play again, and it says yes the loop continue, otherwise it doesn’t

a possibility is:

let keepPlaying = true;

while (keepPlaying) {
   // play a game

   //ask user if want to continue
   if (/* user says no */) {
      keepPlaying = false;
   }
}

this will also make it possible to restart from the beginning if at any point there is an invalid input (search about keywords break and continue , they are useful for loops)