Skip to content

solved#1801

Open
vladahvala wants to merge 1 commit intomate-academy:masterfrom
vladahvala:master
Open

solved#1801
vladahvala wants to merge 1 commit intomate-academy:masterfrom
vladahvala:master

Conversation

@vladahvala
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

Excellent work on this task! Your script successfully meets all the requirements by dynamically adding labels and placeholders to the form inputs. The logic is solid and everything functions as expected, so I am approving your solution.

As a small suggestion for future improvement, consider using .forEach() instead of .map() when you are iterating over elements to perform actions, like modifying the DOM. While .map() works here, .forEach() is semantically more accurate for this use case because you aren't using the new array that .map() returns. This is a minor point about idiomatic code, and your current implementation is great. Keep up the fantastic 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 +3 to +17
[...document.querySelectorAll('form input')].map((input) => {
const label = document.createElement('label');

label.className = 'field-label';
label.setAttribute('for', input.id);
label.textContent = input.name;

const placeholder = input.name.charAt(0).toUpperCase() + input.name.slice(1);

input.placeholder = placeholder;

input.before(label);

return input;
});

Choose a reason for hiding this comment

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

While using .map() works here, it's generally intended for creating a new array from an existing one. Since you are performing actions with side effects (modifying the DOM) and not using the new array that .map() returns, using .forEach() would be more semantically correct for this situation.

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