Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
8531191
object prep
MattCarolus10 Nov 5, 2026
e06f169
Add console log to test pickFromArray with quotes array
MattCarolus10 Nov 12, 2026
7d614be
Fix HTML doctype and update title for quote generator app
MattCarolus10 Nov 12, 2026
aab7559
Display a random quote in the quote generator app
MattCarolus10 Nov 12, 2026
faa4b47
Display author name alongside the selected quote in the quote generat…
MattCarolus10 Nov 12, 2026
fd0e859
Refactor quote display logic into showQuote function
MattCarolus10 Nov 12, 2026
9edde22
Call showQuote function to display a random quote and author
MattCarolus10 Nov 12, 2026
2633348
Add event listener to generate a new quote on button click
MattCarolus10 Nov 12, 2026
fee3a39
Add comment to verify random quote selection using pickFromArray
MattCarolus10 Nov 12, 2026
0cd676c
Add interval to automatically display a new quote every 5 seconds
MattCarolus10 Nov 12, 2026
a795949
Remove prep from quote generator branch
MattCarolus10 Nov 12, 2026
f283787
Remove redundant setInterval call for showQuote function
MattCarolus10 Nov 16, 2026
05604a0
Add autoplay button to trigger automatic quote display
MattCarolus10 Nov 16, 2026
209493a
Fix event listener for new quote button in showQuote function
MattCarolus10 Nov 16, 2026
2e220ba
Add character limit section and fix event listener for autoplay button
MattCarolus10 Nov 16, 2026
efc6f75
Fix typo in event listener for autoplay button
MattCarolus10 Nov 16, 2026
d60a441
Refactor autoplay button event listener for improved readability
MattCarolus10 Nov 16, 2026
2cd5000
Remove unrelated prep file
MattCarolus10 Nov 16, 2026
db72b54
Add auto-play status paragraph to index.html
MattCarolus10 Nov 21, 2026
96307ca
Implement toggle functionality for autoplay feature with status update
MattCarolus10 Nov 21, 2026
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
6 changes: 4 additions & 2 deletions Sprint-3/quote-generator/index.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Title here</title>
<title>Quote generator app</title>
<script defer src="quotes.js"></script>
</head>
<body>
<h1>hello there</h1>
<p id="quote"></p>
<p id="author"></p>
<button type="button" id="new-quote">New quote</button>
<button type="button" id="autoplay">Start autoplay</button>
<p id="auto-play-status">Auto-play: Off</p>
</body>
</html>
26 changes: 26 additions & 0 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// pickFromArray(['a','b','c','d']) // maybe returns 'c'

// You don't need to change this function

function pickFromArray(choices) {
return choices[Math.floor(Math.random() * choices.length)];
}
Expand Down Expand Up @@ -490,4 +491,29 @@ const quotes = [
},
];

function showQuote() {
const selectedQuote = pickFromArray(quotes);
document.getElementById("quote").textContent = selectedQuote.quote;
document.getElementById("author").textContent = selectedQuote.author;
}
showQuote();

let autoplayTimer = null;

const autoplayButton = document.getElementById("autoplay");
const autoplayStatus = document.getElementById("auto-play-status");

autoplayButton.addEventListener("click", () => {
if (autoplayTimer === null) {
autoplayTimer = setInterval(showQuote, 5000);
autoplayButton.textContent = "Stop autoplay";
autoplayStatus.textContent = "Auto-play: On";
} else {
clearInterval(autoplayTimer);
autoplayTimer = null;
autoplayButton.textContent = "Start autoplay";
autoplayStatus.textContent = "Auto-play: Off";
}
});

// call pickFromArray with the quotes array to check you get a random quote
Loading