diff --git a/src/scripts/main.js b/src/scripts/main.js index a765fdb1d..9b42143e5 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -1,3 +1,21 @@ 'use strict'; -// write code here +const inputAll = document.querySelectorAll('form input'); + +inputAll.forEach((element) => { + const newLabel = document.createElement('label'); + + newLabel.classList.add('field-label'); + + newLabel.setAttribute('for', element.id); + + const text = element.name.charAt(0).toUpperCase() + element.name.slice(1); + + newLabel.textContent = text; + + element.setAttribute('placeholder', text); + + const container = element.closest('.field'); + + container.appendChild(newLabel); +});