Skip to content

add solution#1834

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

add solution#1834
Yevhen-Srdk wants to merge 2 commits intomate-academy:masterfrom
Yevhen-Srdk:develop

Conversation

@Yevhen-Srdk
Copy link

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

Good effort on this task! Your script correctly identifies the inputs and adds the necessary elements. However, this requires a couple of changes to meet all the requirements.

First, the labels are not correctly linked to the inputs. Because for is a reserved keyword in JavaScript, you must use the label.htmlFor property to set the for attribute. This is a critical fix to ensure clicking the label focuses the input field.

Second, the text formatting for names with hyphens needs adjustment. For example, confirm-password should produce the label CONFIRM PASSWORD, not CONFIRM-PASSWORD. You can achieve this by replacing hyphens with spaces before capitalizing the string.


✨ 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

const inputParent = input.closest('div');

label.classList.add('field-label');
label.for = input.id;

Choose a reason for hiding this comment

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

In JavaScript, to set the for attribute of a label element, you should use the htmlFor property (label.htmlFor). The word for is a reserved keyword in JavaScript, so label.for will not work as expected to link the label to the input.


label.classList.add('field-label');
label.for = input.id;
label.textContent = input.name.toUpperCase();

Choose a reason for hiding this comment

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

This approach works well for single-word names. However, for a name like confirm-password, this would produce CONFIRM-PASSWORD. Based on the expected result image, the label should be CONFIRM PASSWORD. You'll need to handle cases with hyphens by replacing them with a space before capitalizing. This also affects the placeholder text.

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

Great work on this task, you're very close to the solution! You've correctly used label.htmlFor as requested in the previous feedback. The one remaining issue is that the logic for formatting the label text needs to handle kebab-case strings. Currently, your script is set up to handle camelCase, but it should replace hyphens in names like confirm-password with a space to produce the correct label. Please don't worry about the failing checks, as they are caused by an environment issue, not your code. Once you adjust the string formatting, this will be ready for approval!


✨ 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

for (const input of inputs) {
const label = document.createElement('label');
const inputParent = input.closest('div');
const inputName = input.name.split(/(?=[A-Z])/).join(' ');

Choose a reason for hiding this comment

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

This regular expression is designed to split camelCase strings (e.g., userName into user Name), but the requirement is to handle kebab-case strings with hyphens (e.g., confirm-password). You should replace hyphens with spaces instead.

Copy link

@Anton-Kuchmasov Anton-Kuchmasov left a comment

Choose a reason for hiding this comment

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

Good job!

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.

3 participants