-
-
Notifications
You must be signed in to change notification settings - Fork 283
London|26-ITP-January|Alexandru Pocovnicu|Sprint 3| quote generator app #984
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 7 commits
df37abd
31fcc7d
670779a
0015e40
be903f2
17571ba
ea60dd5
405bec9
828dc03
f41fe77
da857e3
a17fc2b
e0c8d35
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,29 @@ const quotes = [ | |
| ]; | ||
|
|
||
| // call pickFromArray with the quotes array to check you get a random quote | ||
|
|
||
| function chooseQuote() { | ||
| const randomQuote = quotes[Math.floor(Math.random() * quotes.length)]; | ||
|
|
||
| const quote = document.getElementById("quote"); | ||
| quote.innerText = randomQuote.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. can we use textContent instead of innerText and why ? |
||
|
|
||
| const author = document.getElementById("author"); | ||
| author.innerText = randomQuote.author; | ||
| } | ||
|
|
||
| window.addEventListener("load", chooseQuote); | ||
|
|
||
| const button = document.getElementById("new-quote"); | ||
| button.addEventListener("click", chooseQuote); | ||
|
|
||
| const autoGenerate = document.getElementById("auto-play-toggle"); | ||
| let interval = null; | ||
| autoGenerate.addEventListener("change", () => { | ||
| if (autoGenerate.checked) { | ||
| interval = setInterval(chooseQuote, 2000); | ||
|
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. what doeas 2000 mean? what are magic numbers ? and how can we handle magic numbers ? |
||
| } else { | ||
| clearInterval(interval); | ||
| interval = null; | ||
|
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. this line may not be necessary, try removing it and see if it works?
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. which line? the "if" starts the interval and without the "else" the interval doesn't stop even after the box is unchecked 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. the line that this comment is on, line 521 which says
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. done |
||
| } | ||
| }); | ||
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.
welldone you have done a good job just a few things:
can we make the line easy to understand research KISS and SOC and DRY. can we do something to avoid repeating the line 496? its used in line 20 too
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.
thank you