diff --git a/week-8/Homework/mandatory/1-practice/1-practice.md b/week-8/Homework/mandatory/1-practice/1-practice.md index 02aa34989..5dc172c3e 100644 --- a/week-8/Homework/mandatory/1-practice/1-practice.md +++ b/week-8/Homework/mandatory/1-practice/1-practice.md @@ -26,6 +26,12 @@ The following endpoint is publicly available from Github +`${owner}` : name of the github account owner; +`${repo}` : name of the repository +`${pull_number}` : number of the pull request + 2. Describe in a sentence what this API endpoint returns when all of the fields are completed? + +A json that contain all comments made on the pull request. diff --git a/week-8/Homework/mandatory/2-fetch-exercise/exercise.js b/week-8/Homework/mandatory/2-fetch-exercise/exercise.js index fb3a39c2a..4869612d5 100644 --- a/week-8/Homework/mandatory/2-fetch-exercise/exercise.js +++ b/week-8/Homework/mandatory/2-fetch-exercise/exercise.js @@ -17,10 +17,12 @@ Open index.html in your browser. Every time you refresh the page, a different greeting should be displayed in the box. */ -fetch('*** Write the API address here ***') - .then(function(response) { - return response.text(); - }) - .then(function(greeting) { - // Write the code to display the greeting text here - }); \ No newline at end of file +fetch("https://codeyourfuture.herokuapp.com/api/greetings") + .then((response) => response.text()) + .then((data) => { + document.getElementById("greeting-text").innerHTML = data; + }) + .catch((error) => { + console.log(error); + }); +// Write the code to display the greeting text here; diff --git a/week-8/Homework/mandatory/2-fetch-exercise/index.html b/week-8/Homework/mandatory/2-fetch-exercise/index.html index e3c9aa43c..923296047 100644 --- a/week-8/Homework/mandatory/2-fetch-exercise/index.html +++ b/week-8/Homework/mandatory/2-fetch-exercise/index.html @@ -1,28 +1,28 @@ - + - - - CodeYourFuture - Fetch - - - - + + + CodeYourFuture - Fetch + + + + - -

A greeting in a random language...

-

+ +

A greeting in a random language...

+

- - - \ No newline at end of file + + + diff --git a/week-8/Homework/mandatory/3-dog-photo-gallery/index.html b/week-8/Homework/mandatory/3-dog-photo-gallery/index.html new file mode 100644 index 000000000..9373052bc --- /dev/null +++ b/week-8/Homework/mandatory/3-dog-photo-gallery/index.html @@ -0,0 +1,30 @@ + + + + + + Dog-photo + + + +
+ +
+
+ +
+ + + diff --git a/week-8/Homework/mandatory/3-dog-photo-gallery/script.js b/week-8/Homework/mandatory/3-dog-photo-gallery/script.js new file mode 100644 index 000000000..55d8d1016 --- /dev/null +++ b/week-8/Homework/mandatory/3-dog-photo-gallery/script.js @@ -0,0 +1,18 @@ +console.log("Hello"); + +const fetchPhoto = () => { + fetch("https://dog.ceo/api/breeds/image/random") + .then((response) => response.json()) + .then((data) => { + let img = (document.getElementById("img").src = data.message); + }) + .catch((error) => { + console.log(error); + }); +}; +let button = document.getElementById("button"); +console.log(button); + +button.addEventListener("click", fetchPhoto); + +window.onload = fetchPhoto(); /// calls the function as soon as it loads diff --git a/week-8/Homework/mandatory/4-programmer-humour/index.html b/week-8/Homework/mandatory/4-programmer-humour/index.html new file mode 100644 index 000000000..2d6a14864 --- /dev/null +++ b/week-8/Homework/mandatory/4-programmer-humour/index.html @@ -0,0 +1,15 @@ + + + + + + + Programmer-Humor + + +

Humorous Programmers

+
+ + + + diff --git a/week-8/Homework/mandatory/4-programmer-humour/script.js b/week-8/Homework/mandatory/4-programmer-humour/script.js new file mode 100644 index 000000000..dd77ca405 --- /dev/null +++ b/week-8/Homework/mandatory/4-programmer-humour/script.js @@ -0,0 +1,15 @@ +const fetchData = () => { + fetch("https://xkcd.now.sh/?comic=latest") + .then((response) => response.json()) + .then((data) => { + // console.log(data.img); + let img = document.createElement("img"); + img.src = data.img; + document.getElementById("container").appendChild(img); + }) + .catch((error) => { + console.log(error); + }); +}; + +window.onload = fetchData(); diff --git a/week-8/Homework/mandatory/4-programmer-humour/style.css b/week-8/Homework/mandatory/4-programmer-humour/style.css new file mode 100644 index 000000000..abe17174c --- /dev/null +++ b/week-8/Homework/mandatory/4-programmer-humour/style.css @@ -0,0 +1,16 @@ +@media only screen and (max-width: 600px) { + body { + background-color: lightblue; + } + #container img { + width: 15rem; + height: 5rem; + } + #title { + font-size: medium; + } +} + +#container img { + border: 5px dotted black; +}