Open samjam48 opened 5 years ago
lines 17 - 50 (registerForm listener and loginForm listener).
There is a lot of repeated code that could be refactored.
e.preventDefault() could be stated before the if statements so you don't have it written three times.
e.preventDefault()
The generic statement of these three lines could be turned into a function
warning.textContent = "Please enter a username"; registerForm.appendChild(warning); usernameInput.classList.add("redBorder");
Something like this would make each if statement on line
const warnUser = (message, form, element) => { warning.textContent = message form.appendChild(warning); element.classList.add("redBorder"); } warnUser("Please enter a username", registerForm, usernameInput)
lines 17 - 50 (registerForm listener and loginForm listener).
There is a lot of repeated code that could be refactored.
e.preventDefault()
could be stated before the if statements so you don't have it written three times.The generic statement of these three lines could be turned into a function
Something like this would make each if statement on line