-
Notifications
You must be signed in to change notification settings - Fork 20
[김교연] Sprint4 #75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[김교연] Sprint4 #75
The head ref may contain hidden characters: "Basic-\uAE40\uAD50\uC5F0-sprint4"
Conversation
|
스프리트 미션 하시느라 수고 많으셨어요. |
| @@ -0,0 +1,89 @@ | |||
| document.addEventListener("DOMContentLoaded", function () { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
굿굿 이렇게 하면 로드가 완료된 후 자바스크립트가 실행 되는 것을 보장받을 수 있겠네요 👍👍
| function validateEmail(email) { | ||
| const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/; | ||
| return emailRegex.test(email); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
크으 ~ 순수 함수로 잘 작성된 함수입니다 👍👍
일관된 타입, 일관된 반환값, 외부의 상태를 변경하지 않는 깔끔한 함수입니다 👍
순수함수: 부수효과가 없는 함수 즉, 어떤 함수에 동일한 인자를 주었을 때 항상 같은 값을 리턴하는 함수
| const isEmailValid = emailInput.value && validateEmail(emailInput.value); | ||
| const isPasswordValid = | ||
| passwordInput.value && passwordInput.value.length >= 8; | ||
| const isFormValid = isEmailValid && isPasswordValid; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
별칭(isEmailValid, isPAsswordValid)을 적절히 선언하여 가독성이 너무 좋습니다 ! 👍
| validateInputs(); | ||
| } | ||
|
|
||
| emailInput.addEventListener("input", checkEmail); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(참고/선택) 이벤트 객체를 활용해볼 수도 있습니다 !
<input id="text" />document.getElementById("text")
.addEventListener("input", (e) => {
console.log('$$ e', e.target.value);
e.target.style = "background-color: red"
});이렇게 하면 부가적인 전역 변수 선언을 줄이며 코드를 작성 하는 데에 도움이 될 수 있을거예요 ! 😊
| function checkPassword() { | ||
| if (passwordInput.value.length < 8) { | ||
| passwordError.textContent = "비밀번호를 8자 이상 입력해주세요."; | ||
| passwordError.style.display = "block"; | ||
| passwordInputBorder.classList.add("error-border"); | ||
| } else { | ||
| passwordError.style.display = "none"; | ||
| passwordInputBorder.classList.remove("error-border"); | ||
| passwordInputBorder.classList.add("success-border"); | ||
| } | ||
| validateInputs(); | ||
| } | ||
|
|
||
| /* 비밀번호 확인 input */ | ||
| function checkPassword2() { | ||
| if (checkPasswordInput.value.length < 8) { | ||
| checkPasswordInputBorder.classList.add("error-border"); | ||
| } else { | ||
| checkPasswordInputBorder.classList.remove("error-border"); | ||
| checkPasswordInputBorder.classList.add("success-border"); | ||
| } | ||
| validateInputs(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1, 2와 같은 의미를 알 수 없는 함수명은 지양하는게 좋아요.
아마 validateConfirmPassword와 같은 의미를 지닌 것으로 보여요.
기존 checkPassword와 다르게 "비밀번호 확인 유효성 검사" 라는 명확한 목표가 있으니 해당 의미를 함수명으로 사용해보는건 어떨까요 ?
|
수고하셨습니다 교연님 ! 이제 곧 리액트군요 ! 기대가 됩니다 😊😊 |
요구사항
기본
로그인
회원가입
심화
주요 변경사항
스크린샷
멘토에게