Here is my code: const fs = require('fs');
function f() {
var arr = [];
fs.readfile(filename, function(data) {
//some code here
arr.push(someElement);
})
return arr;
}
var result = f();
console.log(result);
//I want an array of elements in it, but this produces an empty array [];
Any help would be very appreciated!