Skip to content

Commit

Permalink
Code review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
benguaraldi committed Feb 27, 2022
1 parent baccec1 commit 14d940f
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions lib/items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export function getRandomItem(deck: Item[], played: Item[]): Item {
if (candidates.length > 0) {
return candidates[Math.floor(Math.random() * candidates.length)];
}
throw new Error("No item candidates");
return deck[Math.floor(Math.random() * deck.length)];
}

Expand All @@ -35,12 +34,7 @@ function tooClose(item: Item, played: Item[]) {
if (played.length < 11)
distance = 110 - 10 * played.length;

for (let j = 0; j < played.length; j++) {
if (Math.abs(item.year - played[j].year) < distance) {
return true;
}
}
return false;
return played.some((p) => Math.abs(item.year - p.year) < distance);
}

export function checkCorrect(
Expand Down

0 comments on commit 14d940f

Please sign in to comment.