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 809 times
Edit
1
Community Evaluations
developer avatar
test js
23/06/2023