Skip to content

Instantly share code, notes, and snippets.

@harrisonmalone
Created June 4, 2020 04:21
Show Gist options
  • Save harrisonmalone/959bede46562c9c0b4d4168b8ac01823 to your computer and use it in GitHub Desktop.
Save harrisonmalone/959bede46562c9c0b4d4168b8ac01823 to your computer and use it in GitHub Desktop.
const readline = require("readline-sync")
const chalk = require("chalk")
const colors = ['red', 'blue', 'green', 'magenta']
console.log("hi, whats your name?")
const name = readline.question("> ")
console.log("whats your favorite color?")
const index = readline.keyInSelect(colors, 'Which color?');
if (index === -1) {
process.exit()
} else {
console.log(chalk[colors[index]](name))
}
{
"name": "node-intro",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"chalk": "^4.0.0",
"lodash": "^4.17.15",
"moment": "^2.26.0",
"node-fetch": "^2.6.0",
"readline-sync": "^1.4.10"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment