Skip to content

Instantly share code, notes, and snippets.

@tlcheah2
Created November 26, 2021 02:06
Show Gist options
  • Save tlcheah2/8ce4561dc574eda6eb4219d5253acb06 to your computer and use it in GitHub Desktop.
Save tlcheah2/8ce4561dc574eda6eb4219d5253acb06 to your computer and use it in GitHub Desktop.
getFileContents before refactor - Clean Code Chapter 3 Example
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