Complete the Capstone Project: Build a Role-Playing Game in Node with readline-sync code example

Example 1: readline sync question

[1] Lion[2] Elephant[3] Crocodile[4] Giraffe[5] Hippo[0] CANCEL Which animal? [1...5 / 0]: 2Ok, Elephant goes to your room.

Example 2: readline sync question

var readlineSync = require('readline-sync'),  animals = ['Lion', 'Elephant', 'Crocodile', 'Giraffe', 'Hippo'],  index = readlineSync.keyInSelect(animals, 'Which animal?');console.log('Ok, ' + animals[index] + ' goes to your room.');

Tags:

Misc Example