From 1609d16ce5251dbc20684ef5e053ba235baeb2ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9E=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=A7=D0=B5=D1=80=D0=BD?= =?UTF-8?q?=D0=B8=D1=88=D0=BE=D0=B2=D0=B0?= Date: Thu, 30 Apr 2026 17:17:47 +0300 Subject: [PATCH 1/2] Solution --- README.md | 4 ++-- package-lock.json | 11 ----------- src/scripts/main.js | 21 +++++++++++++++++++++ 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index d24722b51..00ddf8c66 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/) +1. Replace `elenachernyshova01-cmd` with your Github username in the link + - [DEMO LINK](https://elenachernyshova01-cmd.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/package-lock.json b/package-lock.json index 72d06cb5f..c8e3a59fd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3831,17 +3831,6 @@ "@parcel/core": "^2.16.4" } }, - "node_modules/@pkgjs/parseargs": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", - "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", - "dev": true, - "optional": true, - "peer": true, - "engines": { - "node": ">=14" - } - }, "node_modules/@pkgr/core": { "version": "0.2.9", "resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.2.9.tgz", diff --git a/src/scripts/main.js b/src/scripts/main.js index a765fdb1d..cc0d09362 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -1,3 +1,24 @@ 'use strict'; // write code here +const inputs = document.querySelectorAll('form input'); + +inputs.forEach((input) => { + const { name: inputName, id } = input; + + const label = document.createElement('label'); + + label.classList.add('field-label'); + + label.setAttribute('for', id); + + const labelText = inputName + .replace(/([A-Z])/g, ' $1') + .replace(/^./, (char) => char.toUpperCase()); + + label.textContent = labelText; + + input.placeholder = labelText; + + input.parentElement.prepend(label); +}); From 8693543ec5d432834f92a99b915c1145afcdf5dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9E=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=A7=D0=B5=D1=80=D0=BD?= =?UTF-8?q?=D0=B8=D1=88=D0=BE=D0=B2=D0=B0?= Date: Thu, 30 Apr 2026 17:35:39 +0300 Subject: [PATCH 2/2] Solution --- src/scripts/main.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/scripts/main.js b/src/scripts/main.js index cc0d09362..9d1da2f43 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -12,9 +12,7 @@ inputs.forEach((input) => { label.setAttribute('for', id); - const labelText = inputName - .replace(/([A-Z])/g, ' $1') - .replace(/^./, (char) => char.toUpperCase()); + const labelText = inputName.charAt(0).toUpperCase() + inputName.slice(1); label.textContent = labelText;