Please explain the while loop
const cards = ['diamond', 'spade', 'heart', 'club'];
while (currentCard != 'spade') {currentCard = cards[Math.floor(Math.random() * 4)]; console.log(currentCard);
};
I just don't understand what does the 'not equal spade' really does and why can there be more than 20 outputs... is it because the random floor returns max 10 so the highest number can be 40? But if I multiply by 1 it doesn't work.
Posted Jun 4, 2019, 3:26 PM UTC
36