Javascript final project, stuck on text game with 2d game



Hi there,

I have been working on the final project and creating a game for my nephew.

It starts off all text based but I wanted to make it more complicated so I have decided to try and input a game or two that is 2D.

My first one is in but the issue I am having is this;

The game starts text based and moves into a 2D challenge. When this challenge is completed, I want it to move to more text based game following on from previous.

If the user does not complete the challenge, I want the game to restart the 2D game and not the whole game which is what is happening right now.

Here is the code:

And the HTML for it:

The part that makes the whole game reload in both circumstances is;


Now I don't know how to change this in order to achieve what I want.

Perhaps some sort of function within that function instead?

Any help would be much appreciated!