diff --git a/Week1/js-exercises-week1/exercise1/index.html b/Week1/js-exercises-week1/exercise1/index.html
new file mode 100644
index 000000000..e1fd57d56
--- /dev/null
+++ b/Week1/js-exercises-week1/exercise1/index.html
@@ -0,0 +1,14 @@
+
+
+
+ Parcel Sandbox
+
+
+
+
+
+
+
+
+
+
diff --git a/Week1/js-exercises-week1/exercise1/script.js b/Week1/js-exercises-week1/exercise1/script.js
new file mode 100644
index 000000000..00040d3cf
--- /dev/null
+++ b/Week1/js-exercises-week1/exercise1/script.js
@@ -0,0 +1,35 @@
+//function using XMLHttp Request
+
+let xhrObject = new XMLHttpRequest();
+
+xhrObject.addEventListener('error', xhrObjectErrorHandler);
+
+function xhrObjectErrorHandler(event) {
+ console.log('Error');
+}
+xhrObject.onreadystatechange = function() {
+ if (this.readyState == 4 && this.status == 200) {
+
+
+ let xhrObjectJason = JSON.parse(xhrObject.responseText);
+
+
+ let name = `${xhrObjectJason.results[0].name.first} ${xhrObjectJason.results[0].name.last}`;
+ document.body.innerHTML = ` Hello ${name}, you were called using XmlHttpRequest.
`;
+ }
+};
+
+xhrObject.open('GET', 'https://www.randomuser.me/api');
+xhrObject.send();
+
+//function using axios
+
+axios
+ .get('https://www.randomuser.me/api')
+ .then(function(response) {
+ let nameAxios = `${response.data.results[0].name.first} ${response.data.results[0].name.last}`;
+ document.body.innerHTML += ` Hello ${nameAxios}, you were called using Axios.
`;
+ })
+ .catch(function(error) {
+ //console.log(error);
+ });
diff --git a/Week1/js-exercises-week1/exercise2 Programming Humour/app.js b/Week1/js-exercises-week1/exercise2 Programming Humour/app.js
new file mode 100644
index 000000000..61ac49104
--- /dev/null
+++ b/Week1/js-exercises-week1/exercise2 Programming Humour/app.js
@@ -0,0 +1,41 @@
+let header = document.createElement('H1');
+header.innerHTML = `In this webpage you will see the latest post from xkcd.com
+First one is displayed with an XMLHttpRequest and second one is displayed with axios library `;
+document.body.appendChild(header);
+//document.body.appendChild
+
+//function using XMLHttpRequest--------
+
+let xhrObject = new XMLHttpRequest();
+
+xhrObject.onreadystatechange = () => {
+ if (xhrObject.readyState == 4 && xhrObject.status == 200) {
+ let xhrObjectJason = JSON.parse(xhrObject.responseText);
+ let image = document.createElement('img');
+ image.src = xhrObjectJason.img;
+ document.body.appendChild(image);
+ }
+};
+
+xhrObject.open('GET', 'https://xkcd.now.sh/?comic=latest');
+xhrObject.onerror = err => {
+ console.log(err);
+};
+xhrObject.send();
+
+//function using axios--------
+
+axios
+ .get('https://xkcd.now.sh/?comic=latest')
+ .then(function(response) {
+ // handle success
+ let axiosImage = document.createElement('img');
+ axiosImage.src = response.data.img;
+ document.body.appendChild(axiosImage);
+
+ console.log(axiosImage);
+ })
+ .catch(function(error) {
+ // handle error
+ console.log(error);
+ });
diff --git a/Week1/js-exercises-week1/exercise2 Programming Humour/index.html b/Week1/js-exercises-week1/exercise2 Programming Humour/index.html
new file mode 100644
index 000000000..a7b0f9b90
--- /dev/null
+++ b/Week1/js-exercises-week1/exercise2 Programming Humour/index.html
@@ -0,0 +1,12 @@
+
+
+
+ Parcel Sandbox
+
+
+
+
+
+
+
+
diff --git a/Week1/js-exercises-week1/exercise3 dog photo gallery/app.js b/Week1/js-exercises-week1/exercise3 dog photo gallery/app.js
new file mode 100644
index 000000000..53e1e4e4a
--- /dev/null
+++ b/Week1/js-exercises-week1/exercise3 dog photo gallery/app.js
@@ -0,0 +1,58 @@
+//made using xmlhttp request
+
+let xmlObject = new XMLHttpRequest();
+
+function randomDogPhotoXml() {
+ xmlObject.onreadystatechange = function() {
+ if (this.readyState === 4 && this.status === 200) {
+ // Typical action to be performed when the document is ready:
+ let jsonObject = JSON.parse(xmlObject.responseText);
+ let button = document.querySelector('button');
+
+ let image = document.createElement('img');
+ image.setAttribute('width', '150px');
+ image.setAttribute('height', '150px');
+ image.src = jsonObject.message;
+
+ document.body.appendChild(image);
+
+ console.log(image);
+ }
+ };
+
+ xmlObject.open('GET', 'https://dog.ceo/api/breeds/image/random');
+ xmlObject.onerror = err => {
+ console.log(err);
+ };
+ xmlObject.send();
+}
+
+let buttonOne = document.getElementById('buttonOne');
+buttonOne.addEventListener('click', () => {
+ randomDogPhotoXml();
+});
+
+//made using axios
+
+function randomDogPhotoAxios() {
+ axios
+ .get('https://dog.ceo/api/breeds/image/random')
+ .then(function(response) {
+ // handle success
+ let imageAxios = document.createElement('img');
+ imageAxios.src = response.data.message;
+ imageAxios.setAttribute('width', '300px');
+ imageAxios.setAttribute('height', '300px');
+ console.log(imageAxios);
+ document.body.appendChild(imageAxios);
+ })
+ .catch(function(error) {
+ // handle error
+ console.log(error);
+ });
+}
+
+let buttonTwo = document.getElementById('buttonTwo');
+buttonTwo.addEventListener('click', () => {
+ randomDogPhotoAxios();
+});
diff --git a/Week1/js-exercises-week1/exercise3 dog photo gallery/index.html b/Week1/js-exercises-week1/exercise3 dog photo gallery/index.html
new file mode 100644
index 000000000..2efa3cbee
--- /dev/null
+++ b/Week1/js-exercises-week1/exercise3 dog photo gallery/index.html
@@ -0,0 +1,19 @@
+
+
+
+ Random Dog Photo Gallery
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Week1/test.txt.txt b/Week1/test.txt.txt
new file mode 100644
index 000000000..e69de29bb
diff --git a/homework/index.html b/homework/index.html
index 9c8f80c1a..3ed5c3acd 100755
--- a/homework/index.html
+++ b/homework/index.html
@@ -1,23 +1,29 @@
+
+
+
+
+
+
+
+
+
+ HYF-GITHUB
+
+
+
-
-
-
-
-
-
-
-
-
- HYF-GITHUB
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+
+
+
+
+
+
+