Skip to content

Commit e9c75a0

Browse files
committed
this should be it
1 parent 6757af6 commit e9c75a0

2 files changed

Lines changed: 16 additions & 14 deletions

File tree

‎debugging/book-library/index.html‎

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@
22
<html lang="en">
33
<head>
44
<title>Library Books</title>
5-
<meta
6-
charset="utf-8"
7-
>
5+
<meta charset="utf-8" />
86
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
97
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
108
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
119
<link
1210
rel="stylesheet"
1311
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
14-
>
15-
<link rel="stylesheet" type="text/css" href="style.css">
12+
/>
13+
<link rel="stylesheet" type="text/css" href="style.css" />
1614
</head>
1715

1816
<body>
@@ -35,7 +33,7 @@ <h1>Library</h1>
3533
name="title"
3634
placeholder="Title"
3735
required
38-
>
36+
/>
3937
<label for="author">Author: </label>
4038
<input
4139
type="text"
@@ -44,31 +42,32 @@ <h1>Library</h1>
4442
name="author"
4543
placeholder="Author"
4644
required
47-
>
45+
/>
4846
<label for="pages">Pages:</label>
4947
<input
5048
type="number"
5149
class="form-control"
5250
id="pages"
5351
name="pages"
5452
placeholder="Between 1 and 16000"
53+
min="1"
5554
max="16000"
5655
required
57-
>
56+
/>
5857
<label class="form-check-label">
5958
<input
6059
type="checkbox"
6160
class="form-check-input"
6261
id="check"
6362
value=""
64-
>Read
63+
/>Read
6564
</label>
6665
<input
6766
type="submit"
6867
value="Submit"
6968
class="btn btn-primary"
7069
onclick="submit();"
71-
>
70+
/>
7271
</div>
7372
</div>
7473

@@ -93,6 +92,6 @@ <h1>Library</h1>
9392
</tbody>
9493
</table>
9594

96-
<script src="script.js" ></script>
95+
<script src="script.js"></script>
9796
</body>
9897
</html>

‎debugging/book-library/script.js‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@ function populateStorage() {
2323
//via Book function and start render function
2424

2525
function submit() {
26-
const titleInput = document.getElementById("title").value.trimStart();
26+
const titleInput = document.getElementById("title").value.trim();
2727
const authorInput = document.getElementById("author").value.trimStart();
28-
const pagesInput = document.getElementById("pages").value;
28+
const pagesInput = Number(document.getElementById("pages").value);
2929
const checkInput = document.getElementById("check").checked;
3030
if (
3131
titleInput == "" ||
3232
pagesInput == "" ||
3333
authorInput == "" ||
34+
pagesInput == NaN ||
3435
pagesInput < 1 ||
3536
pagesInput > 16000
3637
) {
@@ -92,9 +93,11 @@ function render() {
9293
button.className = "btn btn-warning";
9394
button.textContent = "Delete";
9495
button.addEventListener("click", function () {
96+
const deletedBook = myLibrary[i].title;
9597
myLibrary.splice(i, 1);
98+
9699
render();
97-
alert(`You've deleted title: ${myLibrary[i].title}`);
100+
alert(`You've deleted title: ${deletedBook}`);
98101
});
99102
}
100103
}

0 commit comments

Comments
 (0)