Skip to content

Add task solution#1473

Open
OleksiiHolodok wants to merge 2 commits intomate-academy:masterfrom
OleksiiHolodok:develop
Open

Add task solution#1473
OleksiiHolodok wants to merge 2 commits intomate-academy:masterfrom
OleksiiHolodok:develop

Conversation

@OleksiiHolodok
Copy link

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

I am approving your solution because it correctly implements all the required behavior: two promises, one resolving on .logo click and one rejecting after 3 seconds, with success and error handlers that append the appropriate <div> elements and classes to the page. The core functionality works and matches the specification, so there are no blockers to task completion.

One thing to be aware of: in src/scripts/main.js, querying .logo and immediately doing logo.addEventListener(...) can throw a runtime error if the script executes before the DOM has created the .logo element. In a real project, you’d typically fix this by either wrapping the code in a DOMContentLoaded listener, placing the script at the end of body, or guarding the listener like:

const logo = document.querySelector('.logo');
if (logo) {
  logo.addEventListener('click', () => { /* resolve promise1 */ });
}

There are also a few minor style improvements you could consider, like not using unused parameters in your promise executors and using classList.add instead of reassigning className. Overall, you met the functional requirements well—nice work getting the promises and handlers wired up correctly.


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

Footnotes

  1. Rate AI review example

'use strict';

// write your code here
const logo = document.querySelector('.logo');

Choose a reason for hiding this comment

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

Selecting .logo immediately may return null if the script runs before the DOM is ready. Consider wrapping this code in a DOMContentLoaded handler or ensuring the script runs after the DOM so the element exists.

};

const promise1 = new Promise((resolve) => {
logo.addEventListener('click', () => {

Choose a reason for hiding this comment

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

Calling logo.addEventListener(...) without checking logo can throw if .logo was not found. Guard the call (for example: if (logo) { logo.addEventListener(...); }) or attach the listener after DOM is loaded to avoid runtime errors.

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