From 45279947f1570653ad8be57792d4a2232a11e454 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Wed, 16 Nov 2016 01:41:14 +0200 Subject: [PATCH] doc: small improvements in readline code examples MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Consistent template literals in `console.log()`. 2. === instead of ==. 3. const instead of var. PR-URL: https://github.com/nodejs/node/pull/9628 Reviewed-By: Colin Ihrig Reviewed-By: Michael Dawson Reviewed-By: James M Snell Reviewed-By: Michaƫl Zasso Reviewed-By: Jackson Tian --- doc/api/readline.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/api/readline.md b/doc/api/readline.md index 36c7e4502274bd..fff79817335e3c 100644 --- a/doc/api/readline.md +++ b/doc/api/readline.md @@ -21,7 +21,7 @@ const rl = readline.createInterface({ rl.question('What do you think of Node.js? ', (answer) => { // TODO: Log the answer in a database - console.log('Thank you for your valuable feedback:', answer); + console.log(`Thank you for your valuable feedback: ${answer}`); rl.close(); }); @@ -403,8 +403,8 @@ For instance: `[[substr1, substr2, ...], originalsubstring]`. ```js function completer(line) { - var completions = '.help .error .exit .quit .q'.split(' '); - var hits = completions.filter((c) => { return c.indexOf(line) == 0 }); + const completions = '.help .error .exit .quit .q'.split(' '); + const hits = completions.filter((c) => { return c.indexOf(line) === 0 }); // show all completions if none found return [hits.length ? hits : completions, line]; } @@ -512,7 +512,7 @@ const rl = readline.createInterface({ }); rl.on('line', (line) => { - console.log('Line from file:', line); + console.log(`Line from file: ${line}`); }); ```