how create array with names of files in folder nodejs

  1. Use the fs module to access the file system in Node.js.
  2. Use the readdirSync method to read the contents of a directory synchronously.
  3. Pass the directory path as a parameter to readdirSync to retrieve an array of file names in the specified directory.