Complete the code to import the module needed to read files synchronously.
const fs = require('[1]');
The fs module is used to work with the file system, including reading files synchronously.
Complete the code to read the file 'example.txt' synchronously.
const data = fs.[1]('example.txt', 'utf8');
readFile which is asynchronous and requires a callback.openSync which opens a file descriptor but does not read content.The readFileSync method reads files synchronously and returns the content.
Fix the error in the code to correctly read a file synchronously.
const content = fs.readFileSync('data.txt', '[1]');
The encoding utf8 is the standard text encoding to read files as strings in Node.js.
Fill both blanks to read 'notes.txt' synchronously and store the content in a variable.
const [1] = fs.[2]('notes.txt', 'utf8');
readFile method.We store the file content in a variable named notes and use readFileSync to read synchronously.
Fill all three blanks to read 'config.json' synchronously and parse it as JSON.
const rawData = fs.[1]('config.json', '[2]'); const config = JSON.[3](rawData);
readFile instead of synchronous.We read the file synchronously with readFileSync, specify encoding utf8, then parse the JSON string with JSON.parse.