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
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 http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Programmer Humour</title>
<link rel="stylesheet" href="style.css">
</head>

<body>
<div id="root"></div>
<script src="script.js"></script>
</body>

</html>
22 changes: 22 additions & 0 deletions programmer-humour/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const rootElem = document.getElementById("root");
const img = document.createElement("img");
const title = document.createElement("h1");
const alt = document.createElement("p");
rootElem.appendChild(title);
rootElem.appendChild(img);
rootElem.appendChild(alt);
// function fetchData() {
fetch("https://xkcd.now.sh/?comic=latest")
.then(function (response) {
return response.json();
})
.then(function (data) {
console.log(data);
img.src = data.img;
img.alt = data.alt;
title.innerText = data.title;
alt.innerText = data.alt
})
.catch((error) => {
console.error(error);
})
16 changes: 16 additions & 0 deletions programmer-humour/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

body {
margin: 0;

}

#root {
color: rgb(152, 152, 236);
background-color: rgb(239, 239, 222);
text-align: center;

}