Skip to content

Commit ff58ce9

Browse files
authored
Update script.js
1 parent 7f5941f commit ff58ce9

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎debugging/book-library/script.js‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,14 @@ function addBook() {
3838
// Preprocessing / validation:
3939
// - reject empty or whitespace-only title/author (checked AFTER trim, not before)
4040
// - reject non-numeric or non-positive page counts
41-
if (!title || !author || !pagesRaw || !Number.isFinite(pages) || pages <= 0) {
41+
if (
42+
!title ||
43+
!author ||
44+
!Number.isInteger(pages) ||
45+
pages <= 0
46+
) {
47+
// invalid
48+
}
4249
alert("Please fill all fields with valid values!");
4350
return false;
4451
}

0 commit comments

Comments
 (0)