-
-
Notifications
You must be signed in to change notification settings - Fork 280
Sheffield | 26-ITP-Jan | Mahammad Osman | Sprint 3| Quote generator #1165
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
d5602e4
ecba3c6
149b2c4
1e263d3
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,24 @@ const quotes = [ | |
| ]; | ||
|
|
||
| // call pickFromArray with the quotes array to check you get a random quote | ||
|
|
||
| // getting the input and button elements from the page | ||
| const quoteElement = document.getElementById("quote"); | ||
|
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. document.getElementById() is one of the way of accessing DOM elements. You can explore more DOM methods. |
||
| const authorElement = document.getElementById("author"); | ||
| const buttonElement = document.getElementById("new-quote"); | ||
|
|
||
| function displayRandomQuote() { | ||
| // get a random quote from the quotes array | ||
| const randomQuote = pickFromArray(quotes); | ||
|
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. pickFromArray(quotes) used correctly. |
||
|
|
||
| // update the quote and author elements | ||
| quoteElement.textContent = randomQuote.quote; | ||
| authorElement.textContent = randomQuote.author; | ||
| } | ||
|
|
||
| displayRandomQuote(); // display a random quote when the page loads | ||
|
|
||
| // display a new random quote when button is clicked | ||
| buttonElement.addEventListener("click", () => { | ||
|
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. Event handler used correctly. |
||
| displayRandomQuote(); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,42 @@ | ||
| /** Write your CSS in here **/ | ||
|
|
||
| body { | ||
| font-family: Arial, sans-serif; | ||
| background-color: #d8b4db; | ||
| display: flex; | ||
| flex-direction: column; | ||
| align-items: center; | ||
| justify-content: center; | ||
| height: 100vh; | ||
| margin: 0; | ||
| } | ||
|
|
||
| h1 { | ||
| color: #934a87; | ||
| } | ||
| #quote { | ||
| font-size: 1.5em; | ||
| background-color: #d12fe0; | ||
| color: #f6f9f5; | ||
| margin: 20px; | ||
| text-align: center; | ||
| max-width: 600px; | ||
| padding: 20px; | ||
| border-radius: 10px; | ||
| } | ||
|
|
||
| #author { | ||
| font-size: 1.2em; | ||
| color: #934a87; | ||
| margin-bottom: 20px; | ||
| } | ||
|
|
||
| button { | ||
| padding: 10px 20px; | ||
| font-size: 1em; | ||
| background-color: #d12fe0; | ||
| color: #f6f9f5; | ||
| border: none; | ||
| cursor: pointer; | ||
| border-radius: 50px; | ||
| } |
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.
JavaScript File linked correctly to html.