Skip to content
This repository was archived by the owner on Apr 18, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"liveServer.settings.port": 5501
}
16 changes: 8 additions & 8 deletions book-library/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ function submit() {
alert("Please fill all fields!");
return false;
} else {
let book = new Book(title.value, title.value, pages.value, check.checked);
library.push(book);
let book = new Book(title.value, author.value, pages.value, check.checked);
myLibrary.push(book);
render();
}
}
Expand All @@ -54,7 +54,7 @@ function render() {
let table = document.getElementById("display");
let rowsNumber = table.rows.length;
//delete old table
for (let n = rowsNumber - 1; n > 0; n-- {
for (let n = rowsNumber - 1; n > 0; n-- ){
table.deleteRow(n);
}
//insert updated row and cells
Expand Down Expand Up @@ -90,11 +90,11 @@ function render() {

//add delete button to every row and render again
let delButton = document.createElement("button");
delBut.id = i + 5;
cell5.appendChild(delBut);
delBut.className = "btn btn-warning";
delBut.innerHTML = "Delete";
delBut.addEventListener("clicks", function () {
delButton.id = i + 5;
cell5.appendChild(delButton);
delButton.className = "btn btn-warning";
delButton.innerHTML = "Delete";
delButton.addEventListener("click", function () {
alert(`You've deleted title: ${myLibrary[i].title}`);
myLibrary.splice(i, 1);
render();
Expand Down
17 changes: 17 additions & 0 deletions programmer-humour/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/programmer-humour/style.css">
<title>Programming humour</title>
</head>

<body>
<section id="container">
</section>
<script src="/programmer-humour/index.js"></script>
</body>

</html>
21 changes: 21 additions & 0 deletions programmer-humour/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

const getImages = async () => {

return fetch('https://xkcd.now.sh/?comic=latest').then((data) => {
const response = data.json();
return response;
}).catch(error => {
console.error('Fetch error:', error);
});

}

function render() {
getImages().then((data) => {
const img = document.createElement('img');
img.src = data.img;
document.querySelector('#container').appendChild(img);

})
}
window.onload = render;
26 changes: 13 additions & 13 deletions programmer-humour/readme.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Programmer humour

Who knew programmers could be funny?

Write an function that makes an API call to `https://xkcd.now.sh/?comic=latest`

1. Create a `HTML`, `CSS` and `JavaScript` file to write your code in

- Inside the same file write a program that gets the `json` using Fetch.
- A function should make an API call to the given endpoint: `https://xkcd.now.sh/?comic=latest`
- Log the received data to the console
- Render the `img` property into an `<img>` tag in the DOM
- Incorporate error handling
# Programmer humour
Who knew programmers could be funny?
Write an function that makes an API call to `https://xkcd.now.sh/?comic=latest`
1. Create a `HTML`, `CSS` and `JavaScript` file to write your code in
- Inside the same file write a program that gets the `json` using Fetch.
- A function should make an API call to the given endpoint: `https://xkcd.now.sh/?comic=latest`
- Log the received data to the console
- Render the `img` property into an `<img>` tag in the DOM
- Incorporate error handling
5 changes: 5 additions & 0 deletions programmer-humour/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
body {
display: flex;
justify-content: center;
align-items: center;
}