Birmingham | 26-ITP-May | Toluwalase Tiamiyu | Sprint 3 | Quote Generator App - #1320
Birmingham | 26-ITP-May | Toluwalase Tiamiyu | Sprint 3 | Quote Generator App#1320TTiamiyu wants to merge 3 commits into
Conversation
This comment has been minimized.
This comment has been minimized.
4 similar comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
a317f41 to
4967200
Compare
LonMcGregor
left a comment
There was a problem hiding this comment.
Good work, I have a couple of questions
|
|
||
| // Function to select a random quote and update the HTML elements | ||
| function displayNewQuote() { | ||
| const quoteP = document.querySelector("#quote"); |
There was a problem hiding this comment.
Do you need to use querySelector here? Is there a more efficient method you could use?
There was a problem hiding this comment.
i found that .getElementById() works better and its also easier to read. thank you.
|
|
||
| // 2. Add a click event listener to the "New quote" button | ||
| const newQuoteBtn = document.querySelector("#new-quote"); | ||
| if (newQuoteBtn) { |
There was a problem hiding this comment.
i used it to serve as a form of guardrail instruction - Only attach the event listener if the button actually exists on the page. If it doesn't, skip it and keep running the rest of the app safely.
checking online there are other ways i can achieve the same effect, do you think i should use another method?
|
On the if guard, this works, I wanted to make sure you understood how this worked, no need to change it. Good work on this task, it is complete now. |
Learners, PR Template
Self checklist