Consider the following code:
const cards = ['diamond', 'spade', 'heart', 'club'];
let currentCard;
while (currentCard !== 'spade'){
currentCard = cards[Math.floor(Math.random() * 4)];
console.log(currentCard);
}
The result also logs spade to the console.
Is there any way to avoid this? I want to avoid the last statement from being logged to the console in this while loop.
Thanks in advance!