Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@adi518
Last active April 12, 2018 20:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adi518/84214b150357291e7523179c331f3bc1 to your computer and use it in GitHub Desktop.
Save adi518/84214b150357291e7523179c331f3bc1 to your computer and use it in GitHub Desktop.
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