Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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;
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: react linking to documents 
Javascript :: if operator ternary 
Javascript :: Nextjs mongodb connection setup 
Javascript :: vue js data bind 
Javascript :: ERROR TypeError: By.Subject is not a constructor 
Javascript :: how to create a json server 
Javascript :: how to take yes or no in js 
Javascript :: will console.log will be automatically disabled in react native for development build 
Javascript :: js remove trailling lines 
Javascript :: ionic vue use .env 
Javascript :: von click 
Javascript :: react clear input after button click 
Javascript :: spring boot map json to object in controller 
Javascript :: javascript how to convert string to number 
Javascript :: html select multiple selected values 
Javascript :: scroll to top vue 
Javascript :: how to set dropdown value in textbox using jquery 
Javascript :: jquery async await $.getScript( 
Javascript :: remove the last character from a string in JavaScript, 
Javascript :: react rating stars component 
Javascript :: prototype in javascript class 
Javascript :: ondragover js 
Javascript :: javascript get user from api 
Javascript :: JavaScript Creating Symbol 
Javascript :: mathjax arrow 
Javascript :: how to use two text fields in one single row react js 
Javascript :: jquery onchange event 
Javascript :: validar correo electronico en js 
Javascript :: nodejs sqlite create db if not exists 
Javascript :: how to print hello world in javascript 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =