condense ISBN generator

This commit is contained in:
David 2021-08-01 19:09:54 -04:00
parent fbcd59c7f0
commit 9e4f10a7e0
1 changed files with 1 additions and 8 deletions

View File

@ -158,14 +158,7 @@
ISBN = EAN.slice(3, 12);
var checkdigit =
(11 -
(_.reduce(
ISBN.split(""),
function (sum, num, key) {
return sum + num * (10 - key);
},
0
) %
11)) %
(_.reduce(ISBN.split(""), (s, n, k) => s + n * (10 - k), 0) % 11)) %
11;
return ISBN + (checkdigit == 10 ? "X" : checkdigit);
}