condense ISBN generator
This commit is contained in:
parent
fbcd59c7f0
commit
9e4f10a7e0
@ -158,14 +158,7 @@
|
|||||||
ISBN = EAN.slice(3, 12);
|
ISBN = EAN.slice(3, 12);
|
||||||
var checkdigit =
|
var checkdigit =
|
||||||
(11 -
|
(11 -
|
||||||
(_.reduce(
|
(_.reduce(ISBN.split(""), (s, n, k) => s + n * (10 - k), 0) % 11)) %
|
||||||
ISBN.split(""),
|
|
||||||
function (sum, num, key) {
|
|
||||||
return sum + num * (10 - key);
|
|
||||||
},
|
|
||||||
0
|
|
||||||
) %
|
|
||||||
11)) %
|
|
||||||
11;
|
11;
|
||||||
return ISBN + (checkdigit == 10 ? "X" : checkdigit);
|
return ISBN + (checkdigit == 10 ? "X" : checkdigit);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user