Question: Activity 6 : File Functions in Nodejs fs module The following functions are available to write text to a file. fs . writeFileSync ( file
Activity : File Functions in Nodejs fs module
The following functions are available to write text to a file.
fswriteFileSyncfile data options
fsappendFileSync file data options
fsreadFileSyncpath options
Click on each function and read about it in the Nodejs documentation. In this activity you can
ignore the options parameter and work only with the path and data parameters
Add any dependencies required.
Extract the name of the folders in dirname and write them one by one to a text file
called fileWrite.txt using the fswriteFileSyncfile data
options function.
Extract the name of the folders in dirname again nd write them one by one to a text file
called fileAppend.txt using the fsappendFileSyncfile data
options function.
Open the two files that you have created and note the difference.
Recreate the fullpath name again by reading the folder names from fileAppend.js
using fsreadFileSyncpath options function. Hint use the
replaceAll method for strings and path.sep from the path module to separate the
folder names
Print the recreated full path to the console
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
