Skip to content

Instantly share code, notes, and snippets.

@adi518
Last active Apr 12, 2018
Embed
What would you like to do?
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