Skip to content

add task solution#1480

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

add task solution#1480
Ivan7457 wants to merge 1 commit intomate-academy:masterfrom
Ivan7457:develop

Conversation

@Ivan7457
Copy link

@Ivan7457 Ivan7457 commented Mar 3, 2026

No description provided.

Copy link

@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 on this task! Your solution correctly implements all the requirements: promise1 resolves on a click, and promise2 rejects after a timeout, with both handlers correctly manipulating the DOM.

I am approving your submission. As a point for future improvement, consider how you might reduce code duplication. The logic for creating and appending the message div is repeated in your success and error handlers. You could extract this logic into separate functions to make your code cleaner and more maintainable, following the DRY (Don't Repeat Yourself) principle.

Keep up the great work!


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

Footnotes

  1. Rate AI review example

Comment on lines +19 to +49
promise1
.then(() => {
const div = document.createElement('div');

div.classList.add('message');
div.textContent = 'Promise was resolved!';
body.append(div);
})
.catch(() => {
const div = document.createElement('div');

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

promise2
.then(() => {
const div = document.createElement('div');

div.classList.add('message');
div.textContent = 'Promise was resolved!';
body.append(div);
})
.catch(() => {
const div = document.createElement('div');

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

Choose a reason for hiding this comment

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

The success and error handling logic is repeated for both promise1 and promise2. To make the code cleaner and more maintainable, consider creating two separate functions: one to handle successful promise resolution and one for rejection. You can then pass these functions as arguments to .then() and .catch() for both promises, avoiding code duplication.

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