We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5261709 commit 8460075Copy full SHA for 8460075
index.js
@@ -49,10 +49,14 @@ generateRandomCardButton.addEventListener("click", () => {
49
: card.rarity === "legendary"
50
? 0.025
51
: 0; //add card weight to weight sum
52
- if (number <= weightSum) {
+ if (number <= weightSum && cards.length > 0) {
53
//if random number is less than or equal to weight sum
54
randomCardOutput.innerText = `You got a ${card.rarity} card: ${card.name}`; //display generated random card
55
return; //exit function
56
+ } else {
57
+ alert(
58
+ "No cards in collection! Please add cards to the collection first.",
59
+ ); //alert user that there are no cards in collection
60
}
61
62
});
0 commit comments