Skip to content

Commit 4238d86

Browse files
committed
trying to generate cs joke
1 parent 8726c1b commit 4238d86

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

010-dad jokes/index.html

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,28 @@
99
<body>
1010
<div class="container">
1111
<h3>Don't Laugh Challenge</h3>
12-
<div id="joke" class="joke">What did the hungry computer scientist do? Get a byte to eat!</div>
13-
<div id="joke" class="joke">What are programmers favorite animal? A boo-lion!</div>
14-
<div id="joke" class="joke">What is a software engineers favorite drink? Java chip frappe!</div>
15-
<div id="joke" class="joke">Why couldn't the student use GitHub? They couldn't commit.</div>
12+
<div id="joke" class="joke">// Joke goes here</div>
1613
<button id="jokeBtn" class="btn">Get Another Joke</button>
1714
</div>
1815
<script src="script.js"></script>
19-
16+
<br><br><br>
2017
<div class="container">
2118
<h3>Don't Laugh Challenge: Computer Science Edition</h3>
22-
<div id="joke" class="joke">What did the hungry computer scientist do? Get a byte to eat!</div>
23-
<div id="joke" class="joke">What are programmers favorite animal? A boo-lion!</div>
24-
<div id="joke" class="joke">What is a software engineers favorite drink? Java chip frappe!</div>
25-
<div id="joke" class="joke">Why couldn't the student use GitHub? They couldn't commit.</div>
26-
<button id="jokeBtn" class="btn">Get Another Joke</button>
19+
<button class="btn" onclick="generateCSJoke();">Get Another Joke</button>
2720
</div>
21+
<script language="JavaScript">
22+
var jokes = ["What did the hungry computer scientist do? Get a byte to eat!",
23+
"What are programmers favorite animal? A boo-lion!",
24+
"What is a software engineers favorite drink? Java chip frappe!",
25+
"Why couldn't the student use GitHub? They couldn't commit."];
26+
27+
function generateCSJoke(){
28+
var i = parseInt(Math.random() * jokes.length);
29+
const jokeDiv = document.createElement("div");
30+
const jokeContent = document.createTextNode(jokes[i]);
31+
jokeDiv.appendChild(jokeContent);
32+
document.body.appendChild(jokeDiv);
33+
}
34+
</script>
2835
</body>
2936
</html>

0 commit comments

Comments
 (0)