Skip to content
Open

try1 #1891

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/scripts/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
'use strict';

// write code here

const allInputs = document.querySelectorAll('form input');

function capitalize(str) {
return str.charAt(0).toUpperCase() + str.slice(1);
}

allInputs.forEach((input) => {
const label = document.createElement('label');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line adds an unnecessary class 'class' to the label. The requirements only specify adding the field-label class. Remove this line.

label.classList.add('class');

label.classList.add('field-label');
label.setAttribute('for', input.id);
label.textContent = capitalize(input.name);

input.placeholder = capitalize(input.name);
input.parentElement.append(label);
});
Loading