Skip to content

solution#1517

Open
Ruslan-oss-max0 wants to merge 2 commits into
mate-academy:masterfrom
Ruslan-oss-max0:develop
Open

solution#1517
Ruslan-oss-max0 wants to merge 2 commits into
mate-academy:masterfrom
Ruslan-oss-max0:develop

Conversation

@Ruslan-oss-max0
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

I am requesting changes because the current implementation does not fully meet the checklist requirement that each promise must have both a success and an error handler. In src/scripts/main.js, promise1 is only followed by a .then(...) and is missing a .catch(...) that appends <div class="message error-message">Promise was rejected!</div> to document.body [CHECKLIST ITEM #4, #7]. Similarly, promise2 currently has only a .catch(...) but must also have a .then(...) that appends <div class="message">Promise was resolved!</div> to document.body, even though this promise will reject in practice [CHECKLIST ITEM #4, #6]. These missing handlers are critical because the task explicitly requires both success and error handlers for each promise, not just one type per promise.

To fix this, attach a .catch(...) to promise1 right after its .then(...) chain, and inside that handler create/append the required error-message <div> to document.body. Then, attach a .then(...) to promise2 (before or in the same chain as the existing .catch(...)) that creates/appends the required resolved <div class="message"> to document.body. Once these handlers are added, your logic for resolving on .logo click and rejecting after 3 seconds will be complete and aligned with the checklist. Aside from these handler gaps, the core behaviors you've implemented look good, and you’re very close—fixing these points should bring your solution to full compliance.


✨ 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
Comment on lines +15 to +21
promise1.then(() => {
const div = document.createElement('div');

div.className = 'message';
div.textContent = 'Promise was resolved!';
document.body.appendChild(div);
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing error handler for promise1. Checklist items #4 and #7 require both success and error handlers for each promise; add a .catch to promise1 that appends <div class="message error-message">Promise was rejected!</div> to document.body.

Comment thread src/scripts/main.js Outdated
Comment on lines +23 to +29
promise2.catch(() => {
const div = document.createElement('div');

div.classList.add('message', 'error-message');
div.textContent = 'Promise was rejected!';
document.body.appendChild(div);
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing success handler for promise2. Checklist items #4 and #6 require both success and error handlers for each promise; add a .then to promise2 that appends <div class="message">Promise was resolved!</div> to document.body (even though this promise will reject in practice, the handler still must be present).

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

Your solution is approved because it correctly implements both required promises and their handlers in src/scripts/main.js, matching the task’s functional requirements. promise1 resolves on a .logo click and promise2 rejects after 3 seconds, and in both cases you append the exact required DOM elements (<div class="message">Promise was resolved!</div> and <div class="message error-message">Promise was rejected!</div>), so the core behavior and checklist items are satisfied. There are no critical blockers: the code should run and pass the tests as-is.
One minor improvement: where you call document.querySelector('.logo') near the top of src/scripts/main.js, it would be safer to ensure the element exists before attaching the event listener or to run this logic after DOMContentLoaded, e.g. wrapping the setup in document.addEventListener('DOMContentLoaded', ...) or checking if (logo) { logo.addEventListener(...); }. This isn’t required for task completion but will make your code more robust if the script runs before the DOM is fully loaded or on a page without .logo. Overall, you met the task requirements well and the promise usage and DOM manipulation are clear and correct—nice 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