Skip to content

solution#1360

Open
UArtem87 wants to merge 1 commit intomate-academy:masterfrom
UArtem87:develop
Open

solution#1360
UArtem87 wants to merge 1 commit intomate-academy:masterfrom
UArtem87:develop

Conversation

@UArtem87
Copy link
Copy Markdown

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment thread src/scripts/main.js Outdated

const firstPromise = new Promise((resolve, reject) => {
const timeOutId = setTimeout(() => {
reject(error);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/scripts/main.js Outdated
document.body.addEventListener('click', (e) => {
if (e.button === 0) {
clearTimeout(timeOutId);
resolve();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment thread src/scripts/main.js Outdated

const firstPromise = new Promise((resolve, reject) => {
const timeOutId = setTimeout(() => {
reject(new Error('First promise was rejected'));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/scripts/main.js Outdated
Comment on lines +23 to +27
document.body.addEventListener('mousedown', (e) => {
if (e.button === 0 || e.button === 2) {
resolve('Second promise was resolved');
}
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/scripts/main.js Outdated
Comment on lines +34 to +46
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');
}
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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! ✨

Footnotes

  1. Rate AI review example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants