Updated write file code with proper indentation (#19212)

* Updated write file code with proper indentation

Updated with proper style match and indentation

* Update index.md
This commit is contained in:
FarhanYaseen
2018-10-15 17:14:31 +05:00
committed by A-J Roos
parent d7a7fdbd31
commit 719d40cae0

View File

@ -27,10 +27,10 @@ Node.js code to read file from your computer and return the content to the conso
```javascript ```javascript
const fs = require('fs'); const fs = require('fs');
fs.readFile('input.txt', 'utf-8', (err, data) => { fs.readFile('input.txt', 'utf-8', (err, data) => {
if(err){ if (err) {
console.log(err); console.log(err);
} }
else{ else {
console.log("Content present in input.txt file : " + data.toString()); console.log("Content present in input.txt file : " + data.toString());
} }
}); });
@ -55,10 +55,10 @@ Node.js code to write content into file.
```javascript ```javascript
const fs = require('fs'); const fs = require('fs');
fs.writeFile('output.txt', "New content added", (err, data) => { fs.writeFile('output.txt', "New content added", (err, data) => {
if(err){ if (err) {
console.log(err); console.log(err);
} }
else{ else {
console.log("The file is saved"); console.log("The file is saved");
} }
}); });