diff --git a/src/scripts/main.js b/src/scripts/main.js index a765fdb1d..b0654b89c 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -1,3 +1,21 @@ 'use strict'; -// write code here +const forms = document.querySelectorAll('form'); + +forms.forEach((form) => { + const inputs = form.querySelectorAll('input'); + + inputs.forEach((input) => { + const label = document.createElement('label'); + + label.setAttribute('for', input.id); + label.setAttribute('class', 'field-label'); + label.textContent = input.name.charAt(0).toUpperCase() + input.name.slice(1); + + input.setAttribute( + 'placeholder', + input.name.charAt(0).toUpperCase() + input.name.slice(1), + ); + input.parentNode.insertBefore(label, input); + }); +});