I have the following code:
User.find({},{ firstname: 1, password: 1 }, function(err, users) {
const flattenUsers = _(users).map(({firstname, password}) => ([firstname, password])).flatten().value();
console.log(flattenUsers);
const sorted = flattenUsers.reduce((a, e, i) => (i % 2 || a.push([]), a[a.length - 1].push(e), a), []);
});
I would like to put the variable sorted
out in the global scope, how do I do that? I tried returning but that's not an option it seems, public is not supported in JavaScript, my IDE says it's a TS only thing. What should I do to accomplish my task?