How do you count the number of iterations a while loop has gone though?

In this exercise (Lesson 7: Loops, Module 7: While Loop), how do I log the number of iterations the while loop has gone through before getting the value of ‘spade’?

const cards = [‘diamond’, ‘spade’, ‘heart’, ‘club’];

let currentCard;
while (currentCard != ‘spade’) {
currentCard = cards[Math.floor(Math.random() * 4)];

It worked! Thank you very much!

This topic was automatically closed 18 hours after the last reply. New replies are no longer allowed.