i have written a method to read all the file names and pass it to array. It reads correctly and pushes to array and if i print its showing all values.
However if i try to print the array outside the method, its showing as null. Can anyone help me how it can print outside :
const testFolder = '../features/';
const fs1 = require('fs');
let a = [];
fs1.readdir(testFolder, (err, files) => {
files.forEach(file => {
a.push(file);
});
})
console.log(a);
Now a prints as empty. How to get a with all the values