Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/scripts/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
'use strict';

// write code here
const inputs = document.querySelectorAll('input');
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The task requires getting all input elements from the form tag. This selector will get all input elements on the entire page, which might not be what's intended if there were other inputs outside the form. Consider making the selector more specific, for example, 'form input'.


inputs.forEach((input) => {
const label = document.createElement('label');

label.classList.add('field-label');

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

input.placeholder = input.name[0].toUpperCase() + input.name.slice(1);

input.parentElement.append(label);
});
Loading