Last active
September 19, 2021 19:07
-
-
Save HamidOsouli-zz/9261b11e7922c125b0848d878e5f2c86 to your computer and use it in GitHub Desktop.
Ayandeh Deposit Validator with Javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const checkValidDeposit = (accountNumber) => { | |
if (accountNumber.length < 13){ | |
return false; | |
} | |
let total = Number(accountNumber[11]) * 5; | |
total += Number(accountNumber[10]) * 7; | |
total += Number(accountNumber[9]) * 13; | |
total += Number(accountNumber[8]) * 17; | |
total += Number(accountNumber[7]) * 19; | |
total += Number(accountNumber[6]) * 23; | |
total += Number(accountNumber[5]) * 29; | |
total += Number(accountNumber[4]) * 31; | |
total += Number(accountNumber[3]) * 37; | |
total += Number(accountNumber[2]) * 41; | |
total += Number(accountNumber[1]) * 43; | |
total += Number(accountNumber[0]) * 47; | |
const res = (total % 11); | |
if (res == 1) | |
return false; | |
else { | |
const p = 11 - res; | |
if (p == 11 && Number(accountNumber[12]) != 0) | |
return false; | |
else if (p != 11 && p != Number(accountNumber[12])) | |
return false; | |
else | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment