Getting Error regarding scope in javascript
Anonymous
let cards = ['Diamond', 'Spade', 'Heart', 'Club'];
let currentCard = 'Heart';
while (currentCard !== 'Spade') {
console.log(currentCard);
let currentCard = cards[Math.floor(Math.random() *4)];
}
console.log(currentCard);
Here myConcern is about the error that currentCard is not defined ,eventhough I have declared it globally .
So I am thinking that the error message currentCard is not defined should not come.