prompt() is a blocking function, meaning it pauses the script until the user interacts with it. You would need to separate out your functions and call the next piece with an event listener in your modal.
prompt()