Append to a File

It accepts data to be written to the file.

Append to a file

Let’s implement an appendFile() function that asynchronously appends data to the end of the test.txt file.

We can write to a file with fs.appendFile(). This method accepts two arguments:

  • It accepts a file path.
  • It accepts data to be written to the file.

Add the following code to the file-system.js file:

Get hands-on with 1400+ tech skills courses.