const colorOfSky = () => {
const dusk = true;
let color = 'blue';
if (dusk) {
let color = 'pink';
console.log(color); // pink
}
console.log(color); // blue
};
colorOfSky(); // blue
console.log(color); // ReferenceError
I don’t understand why when we call the function in the result it doesn’t show pink and blue? I see dusk is true so why just blue appears when we call it? Why pink it’s not showing?
Thank you. The code above was took from the lesson. Maybe you should update it in there so the explanation would be correct.
I thought I had it wrong, thinking that the 2 colors should appear. Thank you, again.