@@ -19,37 +19,37 @@ function populateStorage() {
1919 }
2020}
2121
22- const title = document . getElementById ( "title" ) ;
23- const author = document . getElementById ( "author" ) ;
24- const pages = document . getElementById ( "pages" ) ;
25- const check = document . getElementById ( "check" ) ;
22+ const titleInput = document . getElementById ( "title" ) ;
23+ const authorInput = document . getElementById ( "author" ) ;
24+ const pagesInput = document . getElementById ( "pages" ) ;
25+ const readCheckbox = document . getElementById ( "check" ) ;
2626
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
2929function submit ( ) {
3030 if (
31- ! title . value . trim ( ) ||
32- ! author . value . trim ( ) ||
33- ! pages . value . trim ( )
31+ ! titleInput . value . trim ( ) ||
32+ ! authorInput . value . trim ( ) ||
33+ ! pagesInput . value . trim ( )
3434 ) {
3535 alert ( "Please fill all fields!" ) ;
3636 return false ;
3737 } else {
38- let book = new Book ( title . value , author . value , pages . value , check . checked ) ;
38+ let book = new Book ( titleInput . value , authorInput . value , pagesInput . value , readCheckbox . checked ) ;
3939 myLibrary . push ( book ) ;
40- title . value = "" ;
41- author . value = "" ;
42- pages . value = "" ;
43- check . checked = false ;
40+ titleInput . value = "" ;
41+ authorInput . value = "" ;
42+ pagesInput . value = "" ;
43+ readCheckbox . checked = false ;
4444 render ( ) ;
4545 }
4646}
4747
4848function Book ( title , author , pages , check ) {
49- this . title = title ;
50- this . author = author ;
51- this . pages = pages ;
52- this . check = check ;
49+ this . titleInput = title ;
50+ this . authorInput = author ;
51+ this . pagesInput = pages ;
52+ this . readCheckbox = check ;
5353}
5454
5555function render ( ) {
@@ -68,9 +68,9 @@ function render() {
6868 const pagesCell = row . insertCell ( 2 ) ;
6969 const wasReadCell = row . insertCell ( 3 ) ;
7070 const deleteCell = row . insertCell ( 4 ) ;
71- titleCell . textContent = myLibrary [ i ] . title ;
72- authorCell . textContent = myLibrary [ i ] . author ;
73- pagesCell . textContent = myLibrary [ i ] . pages ;
71+ titleCell . textContent = myLibrary [ i ] . titleInput ;
72+ authorCell . textContent = myLibrary [ i ] . authorInput ;
73+ pagesCell . textContent = myLibrary [ i ] . pagesInput ;
7474
7575 //add and wait for action for read/unread button
7676 const changeBut = document . createElement ( "button" ) ;
0 commit comments