Question from the Node.js test

Write a NodeJS program that logs the contents of a file.

Hard

Will this code produce the expected result(i.e. log the contents of filefilename.txt)?
(We assume that the file exists and that it contains text)

const fs = require('fs');
fs.readFile('filename.txt', (err, content) => {
  if (err) throw err;
  console.log(content);
});
Author: Jean-marie CléryStatus: PublishedQuestion passed 878 times
Edit
1
Community EvaluationsNo one has reviewed this question yet, be the first!