Created a file name big.file and stored values
const fs = require('fs');
const file = fscreateWriteStream('./big.file');
for(let i=0; i<= 2; i++) {
file.write('1\r\n2\r\n3\r\n');
}
file.end()
I read the file and I tried to find the count of oddnumbers
const file2 = fs.readFile('./big.file','utf8', (err,lines) = {
if(err) throw err;
console.log(lines);
const numbers = lines.map(Number);
const oddNumbers = numbers.filte(n => n%2 ===1);
console.log('odd number count:', oddNumbers.length);
});
This is my output:
C:\projects\rough>node index.js
1
2
3
C:\projects\rough\index.js:13
const numbers = lines.map(Number);
^