Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 326
London | 26-ITP-May | Edina Kurdi | Sprint 3 | Quote Generator#1426
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?
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
75a11155da7c38f0333ea0fa399fc3c28876b7b0b6f597cffa8b38f0948a58a0bbf207File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,20 @@ | ||
| <!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> | ||
| <script defer src="quotes.js"></script> | ||
| </head> | ||
| <body> | ||
| <h1>hello there</h1> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <title>Quote generator app</title> | ||
| <link rel="stylesheet" href="style.css"> | ||
| <script defer src="quotes.js"></script> | ||
| </head> | ||
| <body> | ||
| <div id="quote-box"> | ||
| <p id="quote"></p> | ||
| <p id="author"></p> | ||
| <button type="button" id="new-quote">New quote</button> | ||
| </body> | ||
| </html> | ||
| </div> | ||
| </body> | ||
| </html> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -19,6 +19,18 @@ | ||
| function pickFromArray(choices) { | ||
| return choices[Math.floor(Math.random() * choices.length)]; | ||
| } | ||
| const quotePar = document.getElementById("quote"); | ||
| const authorPar = document.getElementById("author"); | ||
| const newQuoteBtn = document.getElementById("new-quote"); | ||
| function displayQuote(quoteObj) { | ||
| quotePar.textContent = quoteObj.quote; | ||
| authorPar.textContent = quoteObj.author; | ||
| } | ||
| newQuoteBtn.addEventListener("click", function () { | ||
| displayQuote(pickFromArray(quotes)); | ||
| }); | ||
| // A list of quotes you can use in your app. | ||
| // DO NOT modify this array, otherwise the tests may break! | ||
| @@ -491,3 +503,5 @@ const quotes = [ | ||
| ]; | ||
| // call pickFromArray with the quotes array to check you get a random quote | ||
| console.log(pickFromArray(quotes)); //object gets logged into the console initially | ||
| displayQuote(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. Could consider placing all code that runs once on page load in a single function. For example, you could put it inside the page load callback or create a function named This makes it easier to locate and manage all the code that runs once when the app starts. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,27 @@ | ||
| /** Write your CSS in here **/ | ||
| body { | ||
| background-color: rgb(11, 170, 170); | ||
| color: white; | ||
| font-size: 2rem; | ||
| min-height: 100vh; | ||
| display: flex; | ||
| flex-direction: column; | ||
| align-items: center; | ||
| justify-content: center; | ||
| } | ||
| #quote-box { | ||
| background-color: teal; | ||
| border: 3px solid white; | ||
| padding: 40px; | ||
| border-radius: 10px; | ||
| } | ||
| #new-quote { | ||
| display: block; | ||
| background-color: rgb(11, 170, 170); | ||
| color: white; | ||
| font-size: 1.25rem; | ||
| padding: 10px 24px; | ||
| border-radius: 10px; | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.
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.
Note: After checking, it is better to remove all code not needed by the app (to keep the code clean).