You have been given 3 files containing some data in ./seed. Perform the following operations on the data:
-
Read all files and display the output as an object with file name as key and the contents as array of strings i.e.
{ vegetables: ["carrot", "beans"...], fruits: ["mango"...] }Your code should now accept an optional parameter which allows you to filter records based on first character of the record
eg:- Get all vegetables/fruits/beverages that start with letter `c` Output - { vegetables: ["carrot"], fruits: [] }Bonus for handling error scenarios
-
Add the following items to
beverages.txtusing node:tea hot chocolate coffeeUse the same function to append the following in given files:
fruits.txt: strawberry peach vegetables.txt: pumpkinFunction should return the final content of file in the format shown in 1.
-
Remove the vegetables from
vegetables.txtwhich start with letterc- Function should return the final content of file in the format shown in 1.