Skip to content

Sheffield | 25-ITP-May | Hassan Osman | Quote generator App. #648

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Sprint-3/quote-generator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<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>
Expand Down
23 changes: 23 additions & 0 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
let lastQuote = null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable is unused.


function displayQuote() {
let newQuote;

do {
newQuote = pickFromArray(quotes);
} while (lastQuote &&
newQuote.quote === lastQuote.quote &&
newQuote.author === lastQuote.author
);

document.getElementById("quote").textContent = `"${newQuote.quote}"`;
document.getElementById("author").textContent = `— ${newQuote.author}`;

lastQuote = newQuote;
}

window.addEventListener("DOMContentLoaded", () => {
displayQuote();
document.getElementById("new-quote").addEventListener("click", displayQuote);
});

// DO NOT EDIT BELOW HERE

// pickFromArray is a function which will return one item, at
Expand Down