-
-
Notifications
You must be signed in to change notification settings - Fork 276
London | ITP-Jan-2026 | Ping Wang | Sprint 3 | Quote Generator Sprint 3/quote generator #1036
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -491,3 +491,20 @@ const quotes = [ | |
| ]; | ||
|
|
||
| // call pickFromArray with the quotes array to check you get a random quote | ||
|
|
||
| console.log(pickFromArray(quotes)); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any unnecessary code should be removed to keep our code clean. |
||
|
|
||
| const quoteElement = document.getElementById("quote"); | ||
| const authorElement = document.getElementById("author"); | ||
| const button = document.getElementById("new-quote"); | ||
|
|
||
| function showQuote() { | ||
| const randomQuote = pickFromArray(quotes); | ||
|
|
||
| quoteElement.textContent = randomQuote.quote; | ||
| authorElement.textContent =randomQuote.author; | ||
| } | ||
|
|
||
| button.addEventListener("click", showQuote); | ||
|
|
||
| showQuote(); | ||
|
Comment on lines
+508
to
+510
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Placing all the "run on load" code in one place is a good practice. For examples, function setup() {
// code to be executed on page load
}
window.addEventListener('load', setup);or window.addEventListener('load', function() {
// code to be executed on page load
}); |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,34 @@ | ||
| /** Write your CSS in here **/ | ||
| body { | ||
| font-family: Arial, sans-serif; | ||
| background-color: purple; | ||
| text-align: center; | ||
| padding: 50px; | ||
| } | ||
|
|
||
| .container { | ||
| background: blue; | ||
| padding: 20px; | ||
| border-radius: 10px; | ||
| display: inline-block; | ||
| } | ||
|
|
||
| #quote { | ||
| font-size: 1.5em; | ||
| margin-bottom: 10px; | ||
| } | ||
|
|
||
| #author { | ||
| font-style: italic; | ||
| margin-bottom: 20px; | ||
| } | ||
|
|
||
| button { | ||
| padding: 10px 20px; | ||
| font-size: 1em; | ||
| cursor: pointer; | ||
| } | ||
|
|
||
| .autoplay { | ||
| margin-top: 20px; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the purpose of this element (line 14)?