Skip to content

Commit 5f99008

Browse files
committed
fixed bookPages variable to use for sanitising input, removed bookpagesstring comparison
1 parent 1b6e510 commit 5f99008

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

debugging/book-library/script.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,17 @@ const checkBox = document.querySelector(".check");
2727
//check the right input from forms and if its ok -> add the new book (object in array)
2828
//via Book function and start render function
2929
export function submit() {
30-
const bookTitle = titleElem.value.toString().trim();
31-
const bookAuthor = authorElem.value.toString().trim();
30+
const bookTitle = titleElem.value.trim();
31+
const bookAuthor = authorElem.value.trim();
3232
const bookPages = Number(pagesElem.value);
3333

34-
if (!Number.isInteger(Number(pagesElem.value))){
34+
if (!Number.isInteger(bookPages)){
3535
alert("Pages must be an integer !");
3636
return false;
3737
}
3838
else if (
3939
bookTitle == "" ||
4040
bookAuthor == "" ||
41-
bookPages == ""||
4241
bookPages <= 0
4342
) {
4443
alert("Please fill all fields!");

0 commit comments

Comments
 (0)