Last active
June 10, 2017 04:35
-
-
Save momenbasel/176790d8d8e0d2968a77887d9d575d1a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// init dependecies | |
var readline = require('readline'); | |
var rl = readline.createInterface(process.stdin, process.stdout); | |
var fs = require('fs'); | |
var personDetails = { | |
name : "", | |
sayings: [] | |
} | |
rl.question('what is your name?', function(answer){ | |
personDetails.name = answer; | |
fs.writeFileSync(personDetails.name+'.md', `${personDetails.name} \n ================= \n\n\n\n\n\n\n`); | |
rl.setPrompt(`do you want to ask a question? , ${personDetails.name}`); | |
rl.prompt(); | |
rl.on('line', function(sayings){ | |
personDetails.sayings.push(sayings.trim()); | |
fs.appendFile(personDetails.name+'.md', `*${personDetails.sayings}\n\n\n\n\n`); | |
if(sayings.toLowerCase().trim() === "exit"){ | |
rl.close(); | |
}else { | |
rl.setPrompt('do you want another note? "exit" for leave'); | |
rl.prompt(); | |
} | |
}); | |
}); | |
rl.on('close', () =>{ | |
console.log(' %s you said that %j', personDetails.name , personDetails.sayings); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment