Listing 10.08 - An exits object - Tasks 1 & 2
- Add a couple more places.
- Add a couple more exits.
var Place = function (title) {
this.title = title;
};
var kitchen = new Place("The Kitchen");
var dungeon = new Place("The Dungeon");
var library = new Place("The Library");
var garden = new Place("The Garden");
var exits = {};
exits["north"] = kitchen;
exits["the trapdoor"] = dungeon;
exits["west"] = garden;
exits["up the ladder"] = library;
var keys = Object.keys(exits);
keys.forEach(function (key) {
console.log(key + " goes to " + exits[key].title);
});