Skip to content

add solution#1563

Open
vladyslav-kukhar wants to merge 2 commits into
mate-academy:masterfrom
vladyslav-kukhar:develop
Open

add solution#1563
vladyslav-kukhar wants to merge 2 commits into
mate-academy:masterfrom
vladyslav-kukhar:develop

Conversation

@vladyslav-kukhar

Copy link
Copy Markdown

No description provided.

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

Copy link
Copy Markdown

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 one core requirement is still not fully met: both promise1 and promise2 must have both success and error handlers, and right now each promise only has one type of handler. You’ve correctly implemented promise1 so it resolves on .logo click and appends <div class="message">Promise was resolved!</div> in its then handler, and promise2 correctly rejects after 3 seconds and appends <div class="message error-message">Promise was rejected!</div> in its catch handler. However, promise1 is missing an error handler (.catch) [CHECKLIST ITEM #5], and promise2 is missing a success handler (.then) [CHECKLIST ITEM #4], which means the specification is not fully satisfied.

To fix this, add a .catch to promise1 (near where you currently chain .then) that appends the same error-message div you already use for promise2, e.g. document.body.appendChild(errorDiv) with class="message error-message" and the required text. Then add a .then to promise2 (before the .catch) that appends the same success div.message you use in promise1’s success path; you can either duplicate that logic or extract a small helper like appendSuccessMessage() to keep things DRY. As a minor improvement, consider renaming any unused then/catch parameters (currently named resolve/reject in some handlers) to something like _, value, or error for clarity. Once those handlers are added, your implementation will fully cover the promise behavior the task requires—your current core logic is solid, you just need these final handlers to complete it.


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

div.classList.add('message');
div.textContent = 'Promise was resolved!';

body.append(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.

Checklist items #4 and #5 require success and error handlers for both promises. Here promise1 only has a then handler; consider adding a catch handler that appends the required error-message div similar to promise2’s handler.

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

div.classList.add('message');
div.classList.add('error-message');
div.textContent = 'Promise was rejected!';

body.append(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.

promise2 currently only has an error handler via catch. To satisfy the requirement that both promises have success handlers, add a then handler here that appends the same success div.message used with promise1 when the promise resolves.

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

Copy link
Copy Markdown

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 the two required promises, wires promise1 to resolve on .logo click, and has promise2 reject after 3 seconds, with both then and catch handlers appending the correct message elements to the body. Functionally, this matches the task specification and should work with the tests as expected.

One minor, non-blocking improvement: in src/scripts/main.js, your then/catch handlers currently use parameter names like resolve and reject even though those values are not used. Since resolve/reject usually refer to the executor functions inside new Promise(...), reusing those names for handler arguments can be confusing. You could either omit the unused parameters or rename them to something neutral like _, value, or error to make the intent clearer.

Overall, the logic is solid and fulfills the assignment requirements; any remaining changes would just be for readability and style. Nicely done on getting all the core behaviors and DOM updates in place.


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

Comment thread src/scripts/main.js
document.querySelector('.logo').addEventListener('click', resolve);
});

promise1.then((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.

In these handlers the parameters resolve and reject are never used, and their names can be misleading (they suggest executor functions rather than handler values). Consider renaming them to something like _, value, or error, or omitting them if not needed to improve clarity.

Comment thread src/scripts/main.js
body.append(div);
});

promise1.catch((reject) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Same note as above: the reject parameter isn’t used in this handler. Renaming or removing unused parameters will make the intent of the code clearer.

Comment thread src/scripts/main.js
setTimeout(reject, 3000);
});

promise2.then((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.

Here as well, the resolve parameter in the then handler isn’t used. For cleaner code, consider using a neutral name (like _) or no parameter at all.

Comment thread src/scripts/main.js
body.append(div);
});

promise2.catch((reject) => {

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 parameter in this catch handler is unused; updating the name or removing it would avoid confusion with the executor reject in the promise constructor.

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