Can someone pls help on this ?
- import the ‘fs’ module
- create and export a module with a function “readAndWrite” with following functionality
- should read the content of ‘input.txt’ and write it to ‘duplicate.txt’ using filesystem functions.
- note: specify the encoding string ‘utf8’ while reading the file
- console log the message “Content copied to duplicate.txt”
var fs = require(‘fs’);
fs.readFileSync('input.txt', 'utf8', (err, data) =>
{
if (err) throw err;
fs.writeFileSync('duplicate.txt', data, (err) =>
{
if (err) throw err;
console.log('Content copied to duplicate.txt');
}
)
}
New contributor
Nanthakumar Rajagopal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.