Skip to content

Commit

Permalink
Revert
Browse files Browse the repository at this point in the history
  • Loading branch information
OshekharO authored Jul 13, 2024
1 parent e337d62 commit 0f99ee8
Showing 1 changed file with 0 additions and 32 deletions.
32 changes: 0 additions & 32 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,6 @@ const stopCheckBtn = document.getElementById("stop-check-btn");

let updateNumbers;

// Function to perform Luhn check (standard and Amex)
function isValidCreditCard(number) {
// Remove non-digit characters
number = number.replace(/\D/g, '');

// Check if it's potentially a valid credit card number
if (!/^(?:3[47][0-9]{13}|4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})$/.test(number)) {
return false;
}

let sum = 0;
let alternate = false;
for (let i = number.length - 1; i >= 0; i--) {
let n = parseInt(number.substring(i, i + 1));
if (alternate) {
n *= 2;
if (n > 9) {
n = (n % 10) + 1;
}
}
sum += n;
alternate = !alternate;
}
return (sum % 10) === 0;
}

checkBtn.addEventListener("click", function () {
const numbers = document.getElementById("numbers").value;
const numberArray = numbers.split("\n").filter((number) => {
Expand Down Expand Up @@ -62,12 +36,6 @@ checkBtn.addEventListener("click", function () {
continue;
}

// Perform Luhn check (handles both standard and Amex)
if (!isValidCreditCard(number)) {
muradList.push(`<span style='color:grey; font-weight:bold;'>Invalid (Luhn Check)</span> | ${number} /OshekherO`);
continue;
}

const randomNumber = Math.random();
const randomFour = Math.floor(Math.random() * 4);
const randomTen = Math.floor(Math.random() * 10);
Expand Down

0 comments on commit 0f99ee8

Please sign in to comment.