Created
November 26, 2021 02:06
-
-
Save tlcheah2/8ce4561dc574eda6eb4219d5253acb06 to your computer and use it in GitHub Desktop.
getFileContents before refactor - Clean Code Chapter 3 Example
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 fs = require('fs'); | |
function getFileContents() { | |
const content = fs.readFileSync('./random-word.csv', { encoding: 'utf8' }); | |
const words = content.split(',').map((word) => { | |
return word.trim(); | |
}); | |
return words; | |
} | |
console.log('Start reading file'); | |
console.log('file contents', getFileContents()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment