Last active
July 15, 2019 10:53
-
-
Save Giorgiosaud/08c33e8d3cc51ae0f62eeff1d69aebf9 to your computer and use it in GitHub Desktop.
Ultra Simple Rut Validator Js
This file contains hidden or 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
| export default function(rut){ | |
| const toValidate=rut.slice(-1).toUpperCase(); | |
| let validador=11-rut.toString().split('').reverse().reduce((sum,el,i)=>sum+=el*(i%6+2),0)%11; | |
| validador==10?'K':validador; | |
| return validador===toValidate; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment