I'm quite new to arrow functions. I've googled A LOT and can't find why this isn't working as expected: I get the following console logs while I expect to get both times the same result:
undefined
301b77
Why isn't the inner arrow function passing its return value to the outer function? Note that only the inner console.log is working
const newHash = (bytes) => {
return crypto.randomBytes(bytes, (err, buf) => {
if (err) throw err;
let result = buf.toString('hex');
console.log(result);
return result
})
}
console.log(newHash(3))
Thanks in advance! Juan