Skip to content

Instantly share code, notes, and snippets.

@yychen
Created February 25, 2024 07:51
Show Gist options
  • Save yychen/9d8aa2ec25357856b9df0a08817d54d6 to your computer and use it in GitHub Desktop.
Save yychen/9d8aa2ec25357856b9df0a08817d54d6 to your computer and use it in GitHub Desktop.
const readline = require('readline')
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
})
function question(query) {
return new Promise((resolve) => {
rl.question(query, (answer) => {
resolve(answer)
})
})
}
async function main() {
const name = await question('What is your name? ')
console.log(`Hello, ${name}!`)
rl.close()
}
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment