diff --git a/apps/site/pages/en/learn/command-line/accept-input-from-the-command-line-in-nodejs.md b/apps/site/pages/en/learn/command-line/accept-input-from-the-command-line-in-nodejs.md index 99a040434ca79..5cc09c186e457 100644 --- a/apps/site/pages/en/learn/command-line/accept-input-from-the-command-line-in-nodejs.md +++ b/apps/site/pages/en/learn/command-line/accept-input-from-the-command-line-in-nodejs.md @@ -36,6 +36,21 @@ rl.question(`What's your name?`, name => { console.log(`Hi ${name}!`); rl.close(); }); +``` +or you could use a promise +```mjs +import readline from "node:readline/promises"; + +const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout, +}); + +const name = await rl.question("What's your name? "); +rl.close() + +console.log(`Hi ${name}!`); + ``` This piece of code asks the user's _name_, and once the text is entered and the user presses enter, we send a greeting.