|
9 | 9 | <body>
|
10 | 10 | <div class="container">
|
11 | 11 | <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> |
16 | 13 | <button id="jokeBtn" class="btn">Get Another Joke</button>
|
17 | 14 | </div>
|
18 | 15 | <script src="script.js"></script>
|
19 |
| - |
| 16 | + <br><br><br> |
20 | 17 | <div class="container">
|
21 | 18 | <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> |
27 | 20 | </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> |
28 | 35 | </body>
|
29 | 36 | </html>
|
0 commit comments