diff --git a/week-8/Homework/mandatory/1-practice/1-practice.md b/week-8/Homework/mandatory/1-practice/1-practice.md index 02aa34989..901790ae5 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} - github username +{repo} - repository name +{pull_number} - pull request number + 2. Describe in a sentence what this API endpoint returns when all of the fields are completed? + +It should return all the comments on that specified pull request made on that repo by that owner. diff --git a/week-8/Homework/mandatory/1-practice/numbersFact.html b/week-8/Homework/mandatory/1-practice/numbersFact.html new file mode 100644 index 000000000..0c0d568cd --- /dev/null +++ b/week-8/Homework/mandatory/1-practice/numbersFact.html @@ -0,0 +1,72 @@ + + + + + + + + Number Facts + + +
+
+
+
+

Number Facts

+

Enter a number and get a random fact

+ +
+

+ Number Fact +

+

+
+
+
+
+
+ + + diff --git a/week-8/Homework/mandatory/2-fetch-exercise/exercise.js b/week-8/Homework/mandatory/2-fetch-exercise/exercise.js index fb3a39c2a..7e605fc27 100644 --- a/week-8/Homework/mandatory/2-fetch-exercise/exercise.js +++ b/week-8/Homework/mandatory/2-fetch-exercise/exercise.js @@ -17,10 +17,13 @@ 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(function (response) { + return response.text(); + }) + .then(function (greeting) { + document.getElementById("greeting-text").innerText = greeting; + }) + .catch((error) => { + console.error(error); + }); 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..d664aaa55 --- /dev/null +++ b/week-8/Homework/mandatory/3-dog-photo-gallery/index.html @@ -0,0 +1,32 @@ + + + + + + + + Dog Images Gallery + + +

+ Hit the gray generate button and you will get a new dog image. +

+ +
+ +
+ + + 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..8768914a2 --- /dev/null +++ b/week-8/Homework/mandatory/3-dog-photo-gallery/script.js @@ -0,0 +1,23 @@ +const dogList = document.getElementById("dogList"); +const api_url = "https://dog.ceo/api/breeds/image/random"; + +const button = document.getElementById("getImage"); +button.addEventListener("click", getRandomDog); + +function getRandomDog() { + fetch(api_url) + .then((response) => response.json()) + .then((dog) => { + console.log(dog); + const li = document.createElement("li"); + const img = document.createElement("img"); + img.classList.add("dogImages"); + img.src = dog.message; + li.appendChild(img); + dogList.appendChild(li); + }) + .catch((error) => { + console.log("error!!!"); + console.error(error); + }); +} 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..82d6f5319 --- /dev/null +++ b/week-8/Homework/mandatory/4-programmer-humour/index.html @@ -0,0 +1,16 @@ + + + + + + + Programmer Jokes + + +
+

+ +
+ + + 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..523e5fe6a --- /dev/null +++ b/week-8/Homework/mandatory/4-programmer-humour/script.js @@ -0,0 +1,20 @@ +const api_url = "https://xkcd.now.sh/?comic=latest"; + +let jokeImage = document.getElementById("joke"); +let jokeTitle = document.getElementById("jokeTitle"); + +function getJoke() { + fetch(api_url) + .then((response) => response.json()) + .then((joke) => { + console.log(joke); + jokeTitle.innerText = joke.title; + jokeImage.src = joke.img; + jokeImage.alt = joke.alt; + }) + .catch((error) => { + console.log("error!!!"); + console.error(error); + }); +} +getJoke(); 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..8dadbaebd --- /dev/null +++ b/week-8/Homework/mandatory/4-programmer-humour/style.css @@ -0,0 +1,7 @@ +#container { + text-align: center; +} +img { + display: block; + margin: 0 auto; +}