Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I am approving your solution because it correctly implements all the required behavior: two promises, one resolving on .logo click and one rejecting after 3 seconds, with success and error handlers that append the appropriate <div> elements and classes to the page. The core functionality works and matches the specification, so there are no blockers to task completion.
One thing to be aware of: in src/scripts/main.js, querying .logo and immediately doing logo.addEventListener(...) can throw a runtime error if the script executes before the DOM has created the .logo element. In a real project, you’d typically fix this by either wrapping the code in a DOMContentLoaded listener, placing the script at the end of body, or guarding the listener like:
const logo = document.querySelector('.logo');
if (logo) {
logo.addEventListener('click', () => { /* resolve promise1 */ });
}There are also a few minor style improvements you could consider, like not using unused parameters in your promise executors and using classList.add instead of reassigning className. Overall, you met the functional requirements well—nice work getting the promises and handlers wired up correctly.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Footnotes
src/scripts/main.js
Outdated
| 'use strict'; | ||
|
|
||
| // write your code here | ||
| const logo = document.querySelector('.logo'); |
There was a problem hiding this comment.
Selecting .logo immediately may return null if the script runs before the DOM is ready. Consider wrapping this code in a DOMContentLoaded handler or ensuring the script runs after the DOM so the element exists.
src/scripts/main.js
Outdated
| }; | ||
|
|
||
| const promise1 = new Promise((resolve) => { | ||
| logo.addEventListener('click', () => { |
There was a problem hiding this comment.
Calling logo.addEventListener(...) without checking logo can throw if .logo was not found. Guard the call (for example: if (logo) { logo.addEventListener(...); }) or attach the listener after DOM is loaded to avoid runtime errors.
No description provided.