The generator is made so that cards are randomly generated until spade is reached.

The code is as follows:

const cards = ['diamond', 'spade', 'heart', 'club'];

let currentCard = '';

while (currentCard != 'spade') {
  currentCard = cards[Math.floor(Math.random() * 4)];
  console.log(currentCard)
}

Nothing special, simple ‘while’ loop practice.

Part of Codecademy JS course.