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
11 changes: 11 additions & 0 deletions programmer-humour/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Programmer Humour</title>
<link rel="stylesheet" href="style.css" />
<script defer src="script.js"></script>
</head>
<body></body>
</html>
25 changes: 25 additions & 0 deletions programmer-humour/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
fetch("https://xkcd.now.sh/?comic=latest")
.then((response) => response.json())
.then((data) => generateImg(data));

function generateImg(data) {
const myCont = document.createElement("div");

const myTitle = document.createElement("h3");
myTitle.innerText = data.title;

const myDate = document.createElement("p");
myDate.id = "date";
myDate.innerText = `${data.day}/${data.month}/${data.year}`;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have used semantic HTML elements well here, great work!

const myImg = document.createElement("img");
myImg.setAttribute("src", data.img);
myImg.setAttribute("alt", data.safe_title);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice touch!!!


const mySummary = document.createElement("p");
mySummary.innerText = data.alt;

myCont.append(myTitle, myDate, myImg, mySummary);

document.body.append(myCont);
Comment on lines +22 to +24

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is very clean, very readable, and also shows the correct use of the order of the append Well done @fikretellek !

}
31 changes: 31 additions & 0 deletions programmer-humour/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
* {
padding: 0px;
margin: 0px;
}
body {
background-color: black;
}

div {
width: 300px;
padding: 30px;
display: flex;
flex-direction: column;
gap: 20px;
margin: 0px auto;
margin-top: 30px;
background-color: white;
align-items: center;
border-radius: 10px;

box-shadow: 5px 5px 5px 2px rgba(255, 255, 255, 0.34);

border: solid 1px black;
}
img {
width: auto;
}

#date {
align-self: flex-end;
}