Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions 010-dad jokes/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,30 @@ <h3>Don't Laugh Challenge</h3>
<button id="jokeBtn" class="btn">Get Another Joke</button>
</div>
<script src="script.js"></script>
<br><br><br>
<div id="container2" class="container">
<h3>Don't Laugh Challenge: Computer Science Edition</h3>
<div id="csJoke" class="joke">Click the button for a Computer Science joke!</div>
<button id="csJokeBtn" class="btn" onclick="generateCSJoke();">Get Another Joke</button>
</div>
<script language="JavaScript">
var jokes = ["What did the hungry computer scientist do? Get a byte to eat!",
"What are programmers favorite animal? A boo-lion!",
"What is a software engineers favorite drink? Java chip frappe!",
"Why couldn't the student use GitHub? They couldn't commit."];

function generateCSJoke(){
var removeJoke = document.getElementById("csJoke");
document.getElementById('container2').removeChild(removeJoke);
var i = parseInt(Math.random() * jokes.length);
const jokeDiv = document.createElement("div");
jokeDiv.setAttribute("id", "csJoke");
jokeDiv.setAttribute("class", "joke");
const jokeContent = document.createTextNode(jokes[i]);
jokeDiv.appendChild(jokeContent);
var csJokeButton = document.getElementById("csJokeBtn");
document.getElementById('container2').insertBefore(jokeDiv, csJokeButton);
}
</script>
</body>
</html>