From 381831a92b4895578cdba60c7c1ba7a32f3dc720 Mon Sep 17 00:00:00 2001 From: Skoulskiy Date: Tue, 30 Jun 2026 12:31:22 +0300 Subject: [PATCH 1/3] Added solution --- src/scripts/main.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/scripts/main.js b/src/scripts/main.js index a765fdb1d..d19a3ddc3 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -1,3 +1,17 @@ 'use strict'; // write code here +const inputs = document.querySelectorAll('input'); + +inputs.forEach((input) => { + const label = document.createElement('label'); + + label.classList.add('field-label'); + + label.setAttribute('for', input.id); + label.textContent = input.name || 'Field label'; + + input.placeholder = input.name.toUpperCase(); + + input.before(label); +}); From bace046ff5b3b930f550e21ec8a84bc670ff93a5 Mon Sep 17 00:00:00 2001 From: Skoulskiy Date: Tue, 30 Jun 2026 12:44:29 +0300 Subject: [PATCH 2/3] added fixes --- src/scripts/main.js | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/scripts/main.js b/src/scripts/main.js index d19a3ddc3..f723053f8 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -1,17 +1,28 @@ 'use strict'; // write code here -const inputs = document.querySelectorAll('input'); +const forms = document.querySelectorAll('form'); -inputs.forEach((input) => { - const label = document.createElement('label'); +forms.forEach((form) => { + const inputs = form.querySelectorAll('input'); - label.classList.add('field-label'); + inputs.forEach((input) => { + if (!input.name) { + return; + } - label.setAttribute('for', input.id); - label.textContent = input.name || 'Field label'; + const label = document.createElement('label'); - input.placeholder = input.name.toUpperCase(); + label.classList.add('field-label'); - input.before(label); + label.setAttribute('for', input.id); + label.textContent = input.name || 'Field label'; + + if (input.name) { + const capitalized = input.name[0].toUpperCase() + input.name.slice(1); + + input.placeholder = capitalized; + } + input.parentElement.insertBefore(label, input); + }); }); From 4381215a4337ac3a18ac3194ebf8217a6e053a9c Mon Sep 17 00:00:00 2001 From: Skoulskiy Date: Tue, 30 Jun 2026 13:09:07 +0300 Subject: [PATCH 3/3] added fixes --- src/scripts/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripts/main.js b/src/scripts/main.js index f723053f8..25ffdfd58 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -23,6 +23,6 @@ forms.forEach((form) => { input.placeholder = capitalized; } - input.parentElement.insertBefore(label, input); + input.parentElement.appendChild(label); }); });