diff --git a/src/scripts/main.js b/src/scripts/main.js index a765fdb1d..451944ac5 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -1,3 +1,26 @@ 'use strict'; -// write code here +const formInputs = document.querySelectorAll('form input'); + +function capitalize(text) { + if (!text) { + return ''; + } + + return text.charAt(0).toUpperCase() + text.slice(1); +} + +formInputs.forEach((input) => { + const nameValue = input.name; + const formattedText = capitalize(nameValue); + + input.placeholder = formattedText; + + const label = document.createElement('label'); + + label.classList.add('field-label'); + label.setAttribute('for', input.id); + label.textContent = formattedText; + + input.parentElement.prepend(label); +});