Skip to content

Instantly share code, notes, and snippets.

@Ratstail91
Last active June 17, 2020 05:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ratstail91/4f340dc087073f0974f8035290960c05 to your computer and use it in GitHub Desktop.
Save Ratstail91/4f340dc087073f0974f8035290960c05 to your computer and use it in GitHub Desktop.
//10x programmers (this shitpost took a fucking hour, wtf):
const rl = require('readline').createInterface({
input: process.stdin, output: process.stdout
});
let table = {};
const q = (prompt, key) => () => new Promise(res => rl.question(prompt, answer => res(Object.assign(table, { [key]: answer })) ));
Promise.resolve()
.then(q('what is your name?', 'name'))
.then(q('what is your job?', 'job'))
.then(q('what is your age?', 'age'))
.then(() => console.log(`You are ${table.name} who is a ${table.job} and is ${table.age} years old.`))
.then(() => rl.close())
;
@maufirf
Copy link

maufirf commented Jun 17, 2020

I think I'm starring this for the effort

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment