Last active
April 12, 2018 20:26
-
-
Save adi518/84214b150357291e7523179c331f3bc1 to your computer and use it in GitHub Desktop.
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
isValidIsraeliId: value => { | |
let extrapolationA = 0 | |
const extrapolationB = parseInt(value.charAt(8), 10) | |
for (let i = 0; i < 8; i++) { | |
let extrapolatedDigit = (i % 2 + 1) * value.charAt(i) | |
if (extrapolatedDigit > 9) { | |
const extrapolatedDigitString = extrapolatedDigit.toString() | |
extrapolatedDigit = parseInt(extrapolatedDigitString.charAt(0), 10) | |
extrapolatedDigit += parseInt(extrapolatedDigitString.charAt(1), 10) | |
} | |
extrapolationA += extrapolatedDigit | |
} | |
return (extrapolationA + extrapolationB) % 10 === 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment