-
-
Notifications
You must be signed in to change notification settings - Fork 283
Sheffield | ITP-Jan-26 | Hayriye Saricicek | Sprint 3 | Quote Generator #1151
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 1 commit
1a42b39
e4ad56d
29bc293
3151ee1
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 |
|---|---|---|
| @@ -1,13 +1,45 @@ | ||
| <!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> | ||
| <style> | ||
| body { | ||
| display: grid; | ||
| place-items: center; | ||
| min-height: 100vh; | ||
| margin: 0; | ||
| font-family: Arial, sans-serif; | ||
| text-align: center; | ||
| margin-top: 40px; | ||
| background-color: aqua; | ||
| } | ||
| h1 { | ||
| font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; | ||
| color: green; | ||
| } | ||
|
|
||
| #quote { | ||
| font-size: 45px; | ||
| margin-bottom: 10px; | ||
| color: purple; | ||
| } | ||
| #author { | ||
| font-size: 30px; | ||
| color: red; | ||
| margin-bottom: 10px; | ||
| font-family: Cambria, Cochin, Georgia, Times, "Times New Roman", serif; | ||
| } | ||
| #new-quote { | ||
| padding: 10px 20px; | ||
| font-size: 16px; | ||
| } | ||
| </style> | ||
| <script defer src="quotes.js"></script> | ||
|
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. Correctly linked JavaScript file.
Author
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. thank you |
||
| </head> | ||
| <body> | ||
| <h1>hello there</h1> | ||
| <h1>Welcome to the Quote Generator</h1> | ||
| <p id="quote"></p> | ||
| <p id="author"></p> | ||
| <button type="button" id="new-quote">New quote</button> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,20 @@ | ||
| // DO NOT EDIT ABOVE HERE | ||
| window.addEventListener("DOMContentLoaded", () => { | ||
|
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. You used DOMContentLoaded properly
Author
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. thank you |
||
| const quoteElement = document.getElementById("quote"); | ||
| const authorElement = document.getElementById("author"); | ||
| const newQuoteBtn = document.getElementById("new-quote"); | ||
|
|
||
| function displayRandomQuote() { | ||
| 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. Quote Array is missing look into it.
Author
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. I am not sure if you are referring to the qoute array being defined after the function that uses it? I understood that we had to write our code above the line that says do not edit below so that is what I did. Or is there something else that I am missing? Thank you 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. @mshayriyesaricicek does it currently work as you have it here? the
Author
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. Hi Kyle, thank you for getting back to me. The original code referenced variables and functions before they were defined and although the defer attribute allowed it to work at runtime, I understand that this is not best practice. The code has now been restructured so that dependencies (quotes and pickFromArray) are defined before being used, improving readability and maintainability. Thank you 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. thanks looks good |
||
| quoteElement.textContent = `"${randomQuote.quote}"`; | ||
| authorElement.textContent = randomQuote.author; | ||
| } | ||
|
|
||
| displayRandomQuote(); | ||
|
|
||
| newQuoteBtn.addEventListener("click", displayRandomQuote); | ||
| }); | ||
|
|
||
| // DO NOT EDIT BELOW HERE | ||
|
|
||
| // pickFromArray is a function which will return one item, at | ||
|
|
||
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.
You can use external CSS file and link it to CSS to make code clean.
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.
I didn't see the css file that is why I did in html. I have put all styling in css now and linked in the html. Thank you.