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
20 changes: 19 additions & 1 deletion src/scripts/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
'use strict';
'use strict';
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There's a duplicate 'use strict' directive here — it's redundant and can be removed (the first line already enables strict mode).


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.

This line selects every input in the document, but the task requires getting inputs from the form tag specifically. Consider using document.querySelector('form').querySelectorAll('input') or document.querySelectorAll('form input') so only form inputs are processed.


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

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

// 2. Прив’язуємо label до input через id
label.setAttribute('for', input.id);

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

label.textContent = text;

input.placeholder = text;

// write code here
input.parentElement.prepend(label);
});
Loading