Skip to content

Commit 5c6a07f

Browse files
committed
Fix more code errors
1 parent bda00a9 commit 5c6a07f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ generateRandomCardButton.addEventListener("click", () => {
5050
: card.rarity === "legendary"
5151
? 0.025
5252
: 0; //add card weight to weight sum
53-
if (number <= weightSum && cards.length > 0) {
53+
if (
54+
number <= totalWeight ||
55+
(number <= weightSum && cards.length > 0)
56+
) {
5457
//if random number is less than or equal to weight sum
5558
randomCardOutput.innerText = `You got a ${card.rarity} card: ${card.name}`; //display generated random card
5659
return; //exit function

0 commit comments

Comments
 (0)