From 676b6207888b7bef49b0d78b7a5fcff0926393e5 Mon Sep 17 00:00:00 2001 From: newqou <137334905+newqou@users.noreply.github.com> Date: Sat, 2 Dec 2023 16:45:49 +0200 Subject: [PATCH] solution --- .github/workflows/test.yml | 2 +- README.md | 2 +- package-lock.json | 6 +++--- package.json | 2 +- src/scripts/main.js | 30 +++++++++++++++++++++++++++++- 5 files changed, 35 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b75bd372..ba7659c7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,7 +11,7 @@ jobs: strategy: matrix: - node-version: [12.x] + node-version: [14.x] steps: - uses: actions/checkout@v2 diff --git a/README.md b/README.md index d24722b5..22acc4e9 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://nikkias.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 2df36c99..9c07d735 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1780,9 +1780,9 @@ "dev": true }, "@mate-academy/scripts": { - "version": "1.2.10", - "resolved": "https://registry.npmjs.org/@mate-academy/scripts/-/scripts-1.2.10.tgz", - "integrity": "sha512-BwkVjQfKiybLdpbrILq+bJvJWcROXJtR2CYNl7jACMt/Xrl5dJI3aArMOcX6t/pk+R668BPFaNf7wPRmKeXDLw==", + "version": "1.2.12", + "resolved": "https://registry.npmjs.org/@mate-academy/scripts/-/scripts-1.2.12.tgz", + "integrity": "sha512-ZXmhAzDKVVDqJmO8soZ7EUYDdWm5BkRL4iV4dKTnpUSrWuv3ch8dUmvXZnXhpE/ptP3JqkAb5lfS8CCCj8Yeng==", "dev": true, "requires": { "@octokit/rest": "^17.11.2", diff --git a/package.json b/package.json index 03efddb0..c7183d28 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "@mate-academy/bemlint": "^0.1.1", "@mate-academy/eslint-config": "*", "@mate-academy/linthtml-config": "*", - "@mate-academy/scripts": "^1.2.10", + "@mate-academy/scripts": "^1.2.12", "@mate-academy/stylelint-config": "0.0.11", "@parcel/transformer-sass": "2.10.2", "backstopjs": "^6.2.2", diff --git a/src/scripts/main.js b/src/scripts/main.js index a765fdb1..294e6900 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -1,3 +1,31 @@ 'use strict'; -// write code here +const inputs = document.querySelectorAll('input'); + +inputs.forEach(input => { + const normalizedName = normilizedText(input.name); + + input.placeholder = normalizedName; + + input.insertAdjacentHTML('beforebegin', + ` + + `, + ); +}); + +function normilizedText(text) { + const upperCaseLetter = text.match(/[A-Z]/g) || null; + + let newText = text[0].toUpperCase() + text.slice(1); + + if (upperCaseLetter) { + const index = text.indexOf(upperCaseLetter); + + newText = newText.slice(0, index) + ' ' + newText.slice(index); + } + + return newText; +};