Sync and async styles

Report a typo

You have two functions for reading the file. You need to remove one of the functions so that the string 'Finish' is printed after the contents of the file.

Write a program in JavaScript
const fs = require('fs'); //do not change this line

const dataAsync = fs.readFile('main.js', 'utf-8' , (err, data) => {
console.log(data.split(' ').slice(1)[0]);
}); //you can delete this function at all

const dataSync = fs.readFileSync('main.js', 'utf-8');
console.log(dataSync.split(' ').slice(0)[0]);
//or you can delete two lines above

console.log('Finish');
___

Create a free account to access the full topic