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 98d531e commit 6a74325Copy full SHA for 6a74325
index.js
@@ -50,14 +50,11 @@ generateRandomCardButton.addEventListener("click", () => {
50
: card.rarity === "legendary"
51
? 0.025
52
: 0; //add card weight to weight sum
53
- if (
54
- (number <= totalWeight || number <= weightSum) &&
55
- cards.length > 0
56
- ) {
+ if (number <= weightSum && cards.length > 0) {
57
//if random number is less than or equal to weight sum
58
randomCardOutput.innerText = `You got a ${card.rarity} card: ${card.name}`; //display generated random card
59
return; //exit function
60
- } else {
+ } else if (cards.length === 0) {
61
//if there are no cards in collection
62
alert(
63
"No cards in collection! Please add cards to the collection first.",
0 commit comments