Skip to content

Commit d3f6686

Browse files
committed
applying js
1 parent ee1b677 commit d3f6686

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
URL="https://official-joke-api.appspot.com/random_joke";
2+
button =document.querySelector(".click")
3+
jokecontainer=document.querySelector(".jokecontainer")
4+
5+
button.addEventListener("click", async (event)=>{
6+
console.log("clicked")
7+
8+
9+
let response= await fetch(URL)
10+
let api= await response.json()
11+
let setup=(api.setup)
12+
let punchline=api.punchline
13+
joke=setup+punchline
14+
console.log(joke)
15+
jokecontainer.innerText=joke
16+
17+
18+
})
19+

Projects/RandomJokeGenerator/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</div>
1414

1515
<div class="displayjoke">
16-
<h4 class="joke"> </h4>
16+
<h4 class="jokecontainer"> </h4>
1717
</div>
1818
<button type="button" class="click"> Get a Joke</button>
1919

Projects/RandomJokeGenerator/style.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ body{
3737
margin:10%;
3838
width: 20%;
3939
padding: 5%;
40-
background-color: pink;
40+
background-color: #ffc574;
41+
border-radius: 5%;
4142
}
4243

0 commit comments

Comments
 (0)