diff --git a/index.css b/index.css new file mode 100644 index 00000000..0bc68d00 --- /dev/null +++ b/index.css @@ -0,0 +1,13 @@ + +h1 { + color: red; + text-align: center; + +} +body { + background-color: aquamarine; +} +#window { + height: 400px; + width: 400px; +} \ No newline at end of file diff --git a/index.html b/index.html index 695897ea..6d4f7171 100644 --- a/index.html +++ b/index.html @@ -3,9 +3,16 @@ - Hello Front-End + + -

Hello Front-End

+
+

Welcome To Reddit

+ diff --git a/js.js b/js.js new file mode 100644 index 00000000..9af07fc9 --- /dev/null +++ b/js.js @@ -0,0 +1,35 @@ +let counter = 4 +const theImg = document.createElement('img') + + +document.addEventListener('DOMContentLoaded', () => { + + fetch('https://www.reddit.com/search.json?q=pets+nsfw:no') + .then(res => res.json()) + .then(data => { + console.log(data) + function img() { + theImg.src = data.children[count].data.thumbnail + theImg.style.width = '400px' + theImg.style.height= '400px' + const window = document.getElementById('window') + window.appendChild(theImg) + + + } + document.querySelector('#start').addEventListener('click', () => { + let interval = setInterval(() =>{ + img() + counter+=1 + },1500) + document.querySelector('#stop').addEventListener('click', () => { + theImg.src="" + counter = 4 + clearInterval(interval) + }) + }) + }) + .catch(error => { + console.log('Error',error) + }) +} )