Below is an example of a simple text-based game written in JavaScript, implemented as a single HTML file enclosed within script tags:
This game is a simple text-based game where the player can choose to attack an NPC, heal themselves, or quit the game. The NPC and player have their own health points, and a random amount of damage is dealt with each attack or healing action. The game continues until either the player or the NPC's health reaches zero or the player chooses to quit.