JS window.prompt executing before all code

I’m trying to make a text-based fight simulator for myself based on undertale (why not?) and I’m using JavaScript with an HTML shell so it can run in a browser.

Here is my [UNFINISHED!!] code example:

const enemy = 'Mettaton'.toUpperCase();
const player = window.prompt("Enter your Name, Player").toUpperCase();
let enemyHP = 500;
let enemyMercy = 0;
let playerHP = 150;

document.write(`${enemy} attacks!`);
document.write('<br>');
document.write(`Your stats:`.toUpperCase());
document.write('<br>');
document.write(`${playerHP} HP`);
document.write('<br>');

function yourTurn() {
  let yourMove = window.prompt("FIGHT, ACT, CHECK, or SPARE").toUpperCase();
  switch (yourMove) {
    case "FIGHT" || "fight" || "Fight":
      document.write(`${player} used FIGHT!`);
      document.write('<br>')
      let fightPower = Math.floor(Math.random() * 100 / 5);
      document.write(`${enemy} took ${fightPower} damage!`)
      enemyHP = enemyHP - fightPower
      break;
    default:
      document.write(`Invalid.`)
  }
}

function enemyTurn() {
  let enemyPower = Math.floor(Math.random() * 100 / 3);
  document.write('<br>')
  document.write(`${player} took ${enemyPower} damage!`)
}

yourTurn();
enemyTurn();

For some reason, the prompt that asks for your move (or how you choose to attack) before the stats and the enemy’s name is even displayed!!
How do I get the code above a prompt to run first?