Conversation
Yevhen-Srdk
commented
Mar 10, 2026
- DEMO LINK
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
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
src/scripts/main.js
Outdated
| const inputParent = input.closest('div'); | ||
|
|
||
| label.classList.add('field-label'); | ||
| label.for = input.id; |
There was a problem hiding this comment.
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.
src/scripts/main.js
Outdated
|
|
||
| label.classList.add('field-label'); | ||
| label.for = input.id; | ||
| label.textContent = input.name.toUpperCase(); |
There was a problem hiding this comment.
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.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
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
| for (const input of inputs) { | ||
| const label = document.createElement('label'); | ||
| const inputParent = input.closest('div'); | ||
| const inputName = input.name.split(/(?=[A-Z])/).join(' '); |
There was a problem hiding this comment.
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.