diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..4cb8da5 Binary files /dev/null and b/.DS_Store differ diff --git a/css/main.css b/css/main.css new file mode 100644 index 0000000..5ae1ae8 --- /dev/null +++ b/css/main.css @@ -0,0 +1,5 @@ +* { + text-align: center; + background-color: blue; + color: white; +} \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..49eee00 --- /dev/null +++ b/index.html @@ -0,0 +1,26 @@ + + + + + + + Auto Text + + + + + + +
+
+

Don't Laugh Challenge

+
+

+
+
+ + +
+ + + \ No newline at end of file diff --git a/js/main.js b/js/main.js new file mode 100644 index 0000000..1a56243 --- /dev/null +++ b/js/main.js @@ -0,0 +1,16 @@ +const joke = document.querySelector('.joke'); +const btn = document.getElementById('btn'); +const jokeParagraph = document.querySelector('.joke p'); + +// Getting data from the Api using Fetch with Async Await Syntax. +btn.addEventListener('click', getRandom); +getRandom(); +async function getRandom() { + const jokeRes = await fetch('https://icanhazdadjoke.com/', { + headers: { + 'Accept': 'application/json' + } + }); + const resJson = await jokeRes.json(); + jokeParagraph.innerHTML = resJson.joke; +} \ No newline at end of file