Created
February 25, 2024 07:51
-
-
Save yychen/9d8aa2ec25357856b9df0a08817d54d6 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
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