Skip to content

Commit 6a74325

Browse files
committed
Fix card collection logic code
1 parent 98d531e commit 6a74325

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

index.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,11 @@ generateRandomCardButton.addEventListener("click", () => {
5050
: card.rarity === "legendary"
5151
? 0.025
5252
: 0; //add card weight to weight sum
53-
if (
54-
(number <= totalWeight || number <= weightSum) &&
55-
cards.length > 0
56-
) {
53+
if (number <= weightSum && cards.length > 0) {
5754
//if random number is less than or equal to weight sum
5855
randomCardOutput.innerText = `You got a ${card.rarity} card: ${card.name}`; //display generated random card
5956
return; //exit function
60-
} else {
57+
} else if (cards.length === 0) {
6158
//if there are no cards in collection
6259
alert(
6360
"No cards in collection! Please add cards to the collection first.",

0 commit comments

Comments
 (0)