Skip to content
This repository was archived by the owner on Aug 5, 2021. It is now read-only.

Java script core3 week2/nihal #56

Open
wants to merge 6 commits into
base: master
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
7 changes: 5 additions & 2 deletions week-2/Homework/mandatory/2-fetch-exercise/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ***')
fetch('https://codeyourfuture.herokuapp.com/api/greetings')
.then(function(response) {
return response.text();
})
.then(function(greeting) {
// Write the code to display the greeting text here
let greetingText = document.getElementById("greeting-text")
greetingText.textContent = greeting;
console.log(greetingText)

});
19 changes: 19 additions & 0 deletions week-2/Homework/mandatory/3-dog-photo-gallery/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="">
</head>
<body>
<button id="newBtn">Photo</button>
<ul id="dogPhoto">

</ul>

<script src="style.js" async defer></script>
</body>
</html>
Empty file.
21 changes: 21 additions & 0 deletions week-2/Homework/mandatory/3-dog-photo-gallery/style.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
let newBut = document.getElementById('newBtn');
let photogalary = document.getElementById('dogPhoto');

newBut.addEventListener('click', function() {
let newPhoto = document.createElement('li');
let img = document.createElement('img');
newPhoto.appendChild(img);
photogalary.appendChild(newPhoto);



fetch(`https://dog.ceo/api/breeds/image/random`)
.then(function(response) {
return (response.json());
})

.then(function(data){
img.src = data.message;
})

})
15 changes: 15 additions & 0 deletions week-2/Homework/mandatory/4-programmer-humour/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="style.css">
</head>
<body>

<script src="style.js" async defer></script>
</body>
</html>
Empty file.
13 changes: 13 additions & 0 deletions week-2/Homework/mandatory/4-programmer-humour/style.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
fetch(`https://xkcd.now.sh/?comic=latest`)

.then(function(response) {
return (response.json());
})

.then(function(data) {
console.log(data);

})
.catch(function(error) {
console.log(error)
});