buat dan dapatkan semua file di direktori dengan nodeJS

const fs = require("fs");

// create a new directory 'assets' in the root directory
const folderPath = "./assets";

fs.mkdirSync(folderPath);

// create a file named 'shakespear.txt'
let fileContent = "Now is the winter of our discontent
Made glorious summer by this sun of York;
And all the clouds that lour'd upon our house
In the deep bosom of the ocean buried";

let filePath = folderPath + '/shakespear.txt';
fs.writeFileSync(filepath, fileContent);

// Read and returns the name of all files in the directory
try{
  files = fs.readdirSync(folderPath);
}catch(error){
  console.log(error);
}
Puzzled Porcupine