From 75f464f9485e90077215d0053b081b11214737c9 Mon Sep 17 00:00:00 2001 From: Victoria Neustroeva Date: Thu, 11 Jun 2026 11:52:36 +0300 Subject: [PATCH 1/2] add task solution --- src/scripts/main.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/scripts/main.js b/src/scripts/main.js index a765fdb1d..9a65c675d 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -1,3 +1,21 @@ 'use strict'; -// write code here +const inputElements = [...document.querySelectorAll('input')]; + +inputElements.forEach((input) => { + input.setAttribute('placeholder', formatCamelCase(input.name)); + + const label = document.createElement('label'); + + label.className = 'field-label'; + label.htmlFor = input.name; + label.textContent = formatCamelCase(input.name); + + input.before(label); +}); + +function formatCamelCase(str) { + const withSpaces = str.replaceAll(/([A-Z])/g, ' $1'); + + return withSpaces[0].toUpperCase() + withSpaces.slice(1); +} From 6b4298197bb0802a72dd9eaf2b25532bc2fc1e5c Mon Sep 17 00:00:00 2001 From: Victoria Neustroeva Date: Sun, 14 Jun 2026 22:55:48 +0300 Subject: [PATCH 2/2] add task solution 1 --- src/scripts/main.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/scripts/main.js b/src/scripts/main.js index 9a65c675d..99603cc06 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -1,6 +1,6 @@ 'use strict'; -const inputElements = [...document.querySelectorAll('input')]; +const inputElements = [...document.querySelectorAll('form input')]; inputElements.forEach((input) => { input.setAttribute('placeholder', formatCamelCase(input.name)); @@ -8,10 +8,10 @@ inputElements.forEach((input) => { const label = document.createElement('label'); label.className = 'field-label'; - label.htmlFor = input.name; + label.htmlFor = input.id; label.textContent = formatCamelCase(input.name); - input.before(label); + input.parentElement.append(label); }); function formatCamelCase(str) {