Example 1:
(function () {
let encryptionKey = Math.floor((Math.random() + 1)*4);
console.log (encryptionKey >= 6);
})();
console.log(encryptionKey); //encryptionKey is not defined
Example 2:
(function () {
encryptionKey = Math.floor((Math.random() + 1)*4);
console.log (encryptionKey >= 6);
})();
console.log(encryptionKey); //encryptionKey is logged in the console without any errors
Trying to find out why the value is displayed in the second example.