Last active
July 5, 2019 14:32
-
-
Save atesgoral/c0b97204618b427f0089a0e77f428383 to your computer and use it in GitHub Desktop.
UPC-12 validation
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
['101010101012','614141000036','036000241457','613119000030','614141000035','036000241450','614141000030'] | |
.map(upc=>!(upc.split``.reduce((u,p,c)=>u+p*(3+c*2&3),0)%10)) | |
// [true, true, true, true, false, false, false] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment