javascript ean13 checksum generate
function getLastEan13Digit(ean) {
if (!ean || ean.length !== 12) throw new Error('Invalid EAN 13, should have 12 digits');
const multiply = [1, 3];
let total = 0;
ean.split('').forEach((letter, index) => {
total += parseInt(letter, 10) * multiply[index % 2];
});
const base10Superior = Math.ceil(total / 10) * 10;
return base10Superior - total;
}
Also in JavaScript:
- datatables get all rows
- multiple event with javascript
- how to get focused element in jquery
- undo npm run eject react
- post to /wp-json/wp/v2/media
- javascript regex extract url from string
- javascript is variable undefined
- require a json as a string
- biden trump javascript real time election
- div gets pulled to corner when resizing
- javascript array remove middle
- How to check if a member has a role discord.js
- unshift method in javascript
- settimeout node js
- some in javascript
- new map js
- kotlin read input as int
- drupal tag filter ajax content
- mongodb gte
- sass variables across files
- javascript array to comma separated string
- AAPT: error: resource drawable/ic_stat_icone_app_final_2 (aka com.procam.fleeting.br:drawable/ic_stat_icone_app_final_2) not found.
- How do you call a functional component in React
- how to limit input type max length