fixed bugs

This commit is contained in:
didier amyot committed 2023-12-02 10:14:25 -05:00
1 parent 4b97a2b147
commit ab6e7d323b
2 files changed
+10 -3

No files matched your search

+8 -3
View File
@@ -16,7 +16,7 @@ export function isValidIsbn13(str) {
}
}
check = (10 - (sum % 10)) % 10;
return (check === str[str.length - 1]);
return (check.toString() === str[str.length - 1]);
}
export function isValidIsbn10(str) {
@@ -38,11 +38,16 @@ export function isValidIsbn10(str) {
if (check === 10) {
check = 'X';
}
return (check === str[str.length - 1].toUpperCase());
return (check.toString() === str[str.length - 1].toUpperCase());
}
export function isValidIsbn(str) {
return isValidIsbn13(str) || isValidIsbn10(str);
}
}
console.log(isValidIsbn("ahs"))
console.log(isValidIsbn("0-7754-2153-7"))
console.log(isValidIsbn("978-5-0583-5600-2"))