I'm not sure exactly on the layout of that game and the 3 random cards but in its most basic functionality you could do On click, set a global variable to choose between a number of cards so choose(0,1,2,3,4,5,6...50,51), which can also be displayed as floor(random(52)), if each number relates to a card in the deck. Then you run through it again for as many times as you need to pick a new card. This works well for randomly picking a card, if you want to get into shuffling cards in a deck and drawing them then I would look at arrays.