Skip to content

Commit 241470c

Browse files
vsemozhetbytMylesBorins
authored andcommitted
doc: small improvements in readline code examples
1. Consistent template literals in `console.log()`. 2. === instead of ==. 3. const instead of var. PR-URL: #9628 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Jackson Tian <[email protected]>
1 parent d33520c commit 241470c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

doc/api/readline.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const rl = readline.createInterface({
2121

2222
rl.question('What do you think of Node.js? ', (answer) => {
2323
// TODO: Log the answer in a database
24-
console.log('Thank you for your valuable feedback:', answer);
24+
console.log(`Thank you for your valuable feedback: ${answer}`);
2525

2626
rl.close();
2727
});
@@ -403,8 +403,8 @@ For instance: `[[substr1, substr2, ...], originalsubstring]`.
403403

404404
```js
405405
function completer(line) {
406-
var completions = '.help .error .exit .quit .q'.split(' ');
407-
var hits = completions.filter((c) => { return c.indexOf(line) == 0 });
406+
const completions = '.help .error .exit .quit .q'.split(' ');
407+
const hits = completions.filter((c) => { return c.indexOf(line) === 0 });
408408
// show all completions if none found
409409
return [hits.length ? hits : completions, line];
410410
}
@@ -512,7 +512,7 @@ const rl = readline.createInterface({
512512
});
513513

514514
rl.on('line', (line) => {
515-
console.log('Line from file:', line);
515+
console.log(`Line from file: ${line}`);
516516
});
517517
```
518518

0 commit comments

Comments
 (0)