Repository navigation
London | No Cohort | Daniel Wagner-Hall | Sprint 3 | Quote Generator - #1475
illicitestonion wants to merge 1 commit into
Conversation
| const {quote, author} = pickFromArray(quotes); | ||
| document.getElementById("quote").innerText = quote; | ||
| document.getElementById("author").innerText = author; |
There was a problem hiding this comment.
I notice that the logic for choosing a random quote and updating the quote and author elements appears twice: once in the DOMContentLoaded handler and once in the button click handler. If you ever need to change how a quote is picked or how it is displayed (for example, changing the DOM element IDs or adding extra formatting), you would need to remember to update both places and keep them in sync.
How would it feel to extract those three lines into a small function, and then call that function from both event listeners? That way the behavior for “show a new quote” would live in exactly one place, and both the initial load and the button click would just reuse it. This can make the code easier to maintain and test as the project grows.
To "like" or "dislike" this comment, please follow this link
|
The CYF AI review has left comments. It will only review a PR one time. When you have addressed these comments, please request review again and a volunteer will take a look. |
Learners, PR Template
Self checklist
Task code
CYF-1096
Changelist
Implements quote generator app.