Skip to content

Commit eb4585c

Browse files
committed
Simplify input validation logic in book submission function
1 parent 5c4c90a commit eb4585c

1 file changed

Lines changed: 1 addition & 8 deletions

File tree

debugging/book-library/script.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,7 @@ function submit() {
3131
const authorVal = authorInput.value.trim();
3232
const pagesVal = parseInt(pagesInput.value, 10);
3333

34-
if (
35-
titleVal == null ||
36-
titleVal == "" ||
37-
authorVal == null ||
38-
authorVal == "" ||
39-
isNaN(pagesVal) ||
40-
pagesVal <= 0
41-
) {
34+
if (titleVal === "" || authorVal === "" || isNaN(pagesVal) || pagesVal < 1) {
4235
alert("Please fill all fields!");
4336
return false;
4437
} else {

0 commit comments

Comments
 (0)