Arrays Module 2 Lesson 2

When the second button is tapped:

  • If this button is tapped when there are no cards in the deck, display the message: “No cards in the deck.”

When running both Chris’s M2L2 Solution and also my project, when i first try to draw a card, it’ll display “No cards in the deck.” As intended. However after i add a card first, then draw a card, it’ll be that card, but then when i try to draw a card again, it’ll no longer display, no cards int he deck. Instead it’ll just show my last drawn card. Wondering how to fix this as this issue also occurred in the M2L2 solution as well

@wutodouble

What you are seeing is correct.

When you tap on the second button to draw a card, that card is not deleted from the array. If you have only added 1 card to the array then every time you tap on the draw card button you will get the same card each time.

Try adding more cards to the array then tap on the draw card button. The card drawn should be selected randomly from the array of cards.