diff --git a/src/scripts/main.js b/src/scripts/main.js index a765fdb1d..4c16a9c2f 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -1,3 +1,22 @@ 'use strict'; -// write code here +const allForms = document.querySelectorAll('form'); + +allForms.forEach((form) => { + const inputInThisForm = form.querySelectorAll('input'); + + inputInThisForm.forEach((input) => { + const inputName = input.name; + const formattedName = + inputName.charAt(0).toUpperCase() + inputName.slice(1); + + input.placeholder = formattedName; + + const newLabel = document.createElement('label'); + + newLabel.classList.add('field-label'); + newLabel.htmlFor = input.id; + newLabel.textContent = formattedName; + input.parentElement.appendChild(newLabel); + }); +});