solution#1360
Conversation
UArtem87
commented
Feb 26, 2026
- DEMO LINK https://UArtem87.github.io/js_promises_practice_DOM/
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Good work on setting up the promise structure and event listeners! However, a few changes are needed to meet the core requirements regarding how promises pass data. The main issue is that your resolve and reject calls are not passing the required messages as values.
For example:
- Instead of
resolve(), you should pass the message directly:resolve('First promise was resolved'). - For the rejection, instead of
reject(error), you should pass the required string:reject('First promise was rejected').
Your .then() and .catch() handler functions will then automatically receive these messages as arguments. Please update all promises to pass the required string values upon resolution and rejection.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
|
|
||
| const firstPromise = new Promise((resolve, reject) => { | ||
| const timeOutId = setTimeout(() => { | ||
| reject(error); |
There was a problem hiding this comment.
The reject function should be called with the reason for rejection (in this case, the required message string). Here, you are passing the error function itself as the reason. The requirement is to reject 'with a message First promise was rejected'. You should change this to reject('First promise was rejected'). The message can then be passed to the error function in the .catch() block.
| document.body.addEventListener('click', (e) => { | ||
| if (e.button === 0) { | ||
| clearTimeout(timeOutId); | ||
| resolve(); |
There was a problem hiding this comment.
According to the requirements, the promise should be resolved 'with a message First promise was resolved'. This means you should pass the message as an argument to the resolve function, like resolve('First promise was resolved'). The same principle applies to secondPromise and thirdPromise.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Excellent progress on this task! The logic for resolving the promises is looking great. However, a couple of changes are needed to fully meet the requirements.
The main issue is that firstPromise is being rejected with an Error object instead of the required string message. Please change reject(new Error('...')) to reject('First promise was rejected') to align with the task description.
Additionally, for better efficiency, the event listeners for secondPromise and thirdPromise should be removed after their promises have resolved. For secondPromise, you can add the { once: true } option to addEventListener. For thirdPromise, you'll need to use a named function for your event handler so you can remove it with removeEventListener once the promise is fulfilled.
Keep up the great work!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
|
|
||
| const firstPromise = new Promise((resolve, reject) => { | ||
| const timeOutId = setTimeout(() => { | ||
| reject(new Error('First promise was rejected')); |
There was a problem hiding this comment.
The requirement states that the promise should be rejected with a message (a string), not an Error object. Please change this to reject('First promise was rejected') to match the task description.
| document.body.addEventListener('mousedown', (e) => { | ||
| if (e.button === 0 || e.button === 2) { | ||
| resolve('Second promise was resolved'); | ||
| } | ||
| }); |
There was a problem hiding this comment.
This event listener remains active even after the promise is resolved. This means resolve() will be called on every subsequent left or right click, which is unnecessary. Consider how you might remove the event listener after the first successful resolution.
| document.body.addEventListener('mousedown', (e) => { | ||
| if (e.button === 0) { | ||
| wasClickLeft = true; | ||
| } | ||
|
|
||
| if (e.button === 2) { | ||
| wasClickRight = true; | ||
| } | ||
|
|
||
| if (wasClickLeft && wasClickRight) { | ||
| resolve('Third promise was resolved'); | ||
| } | ||
| }); |
There was a problem hiding this comment.
Similar to the secondPromise, this event listener is never removed. After both clicks have occurred and the promise is resolved, the listener should be cleaned up to avoid unnecessary event handling on future clicks.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Excellent work! Your implementation of the promises and their handlers is flawless. You've successfully addressed all the previous feedback, particularly with correctly rejecting the promise with a string and ensuring event listeners are properly cleaned up. The code is clean, correct, and fully functional. I am happy to approve this solution. Keep up the fantastic work!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨