Skip to content
This repository was archived by the owner on Apr 18, 2025. It is now read-only.

NW6 | Hadika Malik | JS3 | Programmer humour | Week - 3 #307

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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
16 changes: 16 additions & 0 deletions programmer-humour/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!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">
<script defer src="script.js"></script>
<title>Programmer humour</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<img id="comic-img" alt="image for comic">
</body>
<footer></footer>
</html>
13 changes: 13 additions & 0 deletions programmer-humour/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const comicImage = document.getElementById("comic-img");
function fetchComic() {
return fetch("https://xkcd.now.sh/?comic=latest")
.then((data) => data.json());
}

fetchComic().then((comic) => {
comicImage.src = comic.img
console.log(comic);
});



10 changes: 10 additions & 0 deletions programmer-humour/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
body {
background-color: azure;
}

#comic-img {
display: block;
margin-left: auto;
margin-right: auto;
width: 20%;
}