From c01b8c17dd4fa43010fa62f0e7232635c5076e84 Mon Sep 17 00:00:00 2001 From: kateryna Habchak Date: Thu, 21 May 2026 15:38:59 +0200 Subject: [PATCH 1/3] solution --- README.md | 2 +- src/scripts/main.js | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d24722b51..0b6c591b1 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ 1. Replace `` with your Github username in the link - - [DEMO LINK](https://.github.io/js_task_fix_form_DOM/) + - [DEMO LINK](https:///Kateryna7465>.github.io/js_task_fix_form_DOM/) 2. Follow [this instructions](https://mate-academy.github.io/layout_task-guideline/) - Run `npm run test` command to test your code; - Run `npm run test:only -- -n` to run fast test ignoring linter; diff --git a/src/scripts/main.js b/src/scripts/main.js index a765fdb1d..2510d5da4 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -1,3 +1,21 @@ 'use strict'; -// write code here +const inputs = document.querySelectorAll("form input"); + +for (let i = 0; i < inputs.length; i++) { + const input = inputs[i]; + + const label = document.createElement("label"); + label.classname = "field-labe"; + label.setAttribute = ("for", input.id); + + const text = + input.name.charAt(0).toUpperCase() + + input.name.slice(1); + + label.textContent = text; + + input.placeholder = text; + + input.parentElement.insertBefore(label, input); +} From 6d2e6dbd57dadb31b15005ab98599d385df0d61b Mon Sep 17 00:00:00 2001 From: kateryna Habchak Date: Thu, 21 May 2026 15:49:32 +0200 Subject: [PATCH 2/3] solved mistakes --- src/scripts/main.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/scripts/main.js b/src/scripts/main.js index 2510d5da4..4051c6d23 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -1,17 +1,16 @@ 'use strict'; -const inputs = document.querySelectorAll("form input"); +const inputs = document.querySelectorAll('form input'); for (let i = 0; i < inputs.length; i++) { const input = inputs[i]; - const label = document.createElement("label"); - label.classname = "field-labe"; - label.setAttribute = ("for", input.id); + const label = document.createElement('label'); - const text = - input.name.charAt(0).toUpperCase() + - input.name.slice(1); + label.className = 'field-label'; + label.setAttribute = ('for', input.id); + + const text = input.name.charAt(0).toUpperCase() + input.name.slice(1); label.textContent = text; From 695d8f2a473d6d1a6605ed9eb22db342b7470a01 Mon Sep 17 00:00:00 2001 From: kateryna Habchak Date: Thu, 21 May 2026 15:57:10 +0200 Subject: [PATCH 3/3] changed line 11 from label.setAttribute = ('for', input.id) to label.setAttribute('for', input.id); with proper parentheses. --- 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 4051c6d23..8a597712a 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -8,7 +8,7 @@ for (let i = 0; i < inputs.length; i++) { const label = document.createElement('label'); label.className = 'field-label'; - label.setAttribute = ('for', input.id); + label.setAttribute = ("for", input.id); const text = input.name.charAt(0).toUpperCase() + input.name.slice(1);