Skip to content
This repository was archived by the owner on Jan 3, 2023. It is now read-only.
This repository was archived by the owner on Jan 3, 2023. It is now read-only.

11-choose-your-own-adventure play function not correctly checking game.currentRoom #92

@mike-shields-cyf

Description

@mike-shields-cyf

To me, it seems that the play function in this challenge is not correctly checking the value of game.currentRoom.

Here is the play function:

function play(method) {
  if (!game.currentRoom && !game.currentRoom.name) {
    throw new Error(
      `It looks like the game isn't quite right! Make sure your \`${method}\` method is correct`
    );
  }
  console.log(`You are in the ${game.currentRoom.name}.\n`);
  rl.question(
    "Which direction would you like to move? (north/east/south/west) ",
    function (direction) {
      game.move(direction);
      console.log("\n---------------------\n");
      play("move");
    }
  );
}

If the game.start() method fails to set game.currentRoom and game.currentRoom remains as null, the following is logged to the console:

TypeError: Cannot read property 'name' of null

Should it not be expected to see the following logged to the console?:

`It looks like the game isn't quite right! Make sure your `start` method is correct`

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions