[김교연] Sprint4#75
Merged
kiJu2 merged 12 commits intocodeit-bootcamp-frontend:Basic-김교연from Mar 5, 2025
Hidden character warning
The head ref may contain hidden characters: "Basic-\uae40\uad50\uc5f0-sprint4"
Merged
Conversation
Collaborator
|
스프리트 미션 하시느라 수고 많으셨어요. |
kiJu2
approved these changes
Mar 5, 2025
| @@ -0,0 +1,89 @@ | |||
| document.addEventListener("DOMContentLoaded", function () { | |||
Collaborator
There was a problem hiding this comment.
굿굿 이렇게 하면 로드가 완료된 후 자바스크립트가 실행 되는 것을 보장받을 수 있겠네요 👍👍
Comment on lines
+23
to
+26
| function validateEmail(email) { | ||
| const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/; | ||
| return emailRegex.test(email); | ||
| } |
Collaborator
There was a problem hiding this comment.
크으 ~ 순수 함수로 잘 작성된 함수입니다 👍👍
일관된 타입, 일관된 반환값, 외부의 상태를 변경하지 않는 깔끔한 함수입니다 👍
순수함수: 부수효과가 없는 함수 즉, 어떤 함수에 동일한 인자를 주었을 때 항상 같은 값을 리턴하는 함수
Comment on lines
+30
to
+33
| const isEmailValid = emailInput.value && validateEmail(emailInput.value); | ||
| const isPasswordValid = | ||
| passwordInput.value && passwordInput.value.length >= 8; | ||
| const isFormValid = isEmailValid && isPasswordValid; |
Collaborator
There was a problem hiding this comment.
별칭(isEmailValid, isPAsswordValid)을 적절히 선언하여 가독성이 너무 좋습니다 ! 👍
| validateInputs(); | ||
| } | ||
|
|
||
| emailInput.addEventListener("input", checkEmail); |
Collaborator
There was a problem hiding this comment.
(참고/선택) 이벤트 객체를 활용해볼 수도 있습니다 !
<input id="text" />document.getElementById("text")
.addEventListener("input", (e) => {
console.log('$$ e', e.target.value);
e.target.style = "background-color: red"
});이렇게 하면 부가적인 전역 변수 선언을 줄이며 코드를 작성 하는 데에 도움이 될 수 있을거예요 ! 😊
Comment on lines
+112
to
+134
| 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(); | ||
| } |
Collaborator
There was a problem hiding this comment.
1, 2와 같은 의미를 알 수 없는 함수명은 지양하는게 좋아요.
아마 validateConfirmPassword와 같은 의미를 지닌 것으로 보여요.
기존 checkPassword와 다르게 "비밀번호 확인 유효성 검사" 라는 명확한 목표가 있으니 해당 의미를 함수명으로 사용해보는건 어떨까요 ?
Collaborator
|
수고하셨습니다 교연님 ! 이제 곧 리액트군요 ! 기대가 됩니다 😊😊 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
요구사항
기본
로그인
회원가입
심화
주요 변경사항
스크린샷
멘토에게