Skip to content

Commit

Permalink
Fix isPrime bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcus Näslund committed Nov 10, 2023
1 parent e181b6b commit bef5a6d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ const isPrime = number => {
if (allPrimes.has(number)) return true;
if (number % 2 === 0) return false;

allPrimes.forEach(prime => {
for (prime of allPrimes) {
if (number % prime === 0) {
console.log(`${number} is divisible by ${prime}`);
return false;
}
});
};

allPrimes.add(number);
return true;
Expand All @@ -51,7 +52,7 @@ const createCard = (index, prime = false) => {
cardContainer.appendChild(card);

if (isSexyPrime(index)) {
card.innerHTML += '<i class="sexy fa fa-heart"></i>';
card.innerHTML = '<i class="sexy fa fa-heart"></i>' + card.innerHTML;
}
};

Expand Down Expand Up @@ -86,7 +87,7 @@ const handleInfiniteScroll = () => {

window.onload = () => {
UIshowComposites.checked = localStorage.getItem("showComposites") === "true";
createCards(10);
createCards(1000);
}
window.addEventListener("scroll", handleInfiniteScroll);

Expand Down

0 comments on commit bef5a6d

Please sign in to comment.