-
Notifications
You must be signed in to change notification settings - Fork 9
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
[문자열 덧셈 계산기] 이혁 미션 제출합니다. #571
base: main
Are you sure you want to change the base?
Conversation
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.
정규 표현식을 사용하고 substring()으로 커스텀 구분자로 추출한 로직이 인상깊었어요.
2주차도 기대하겠습니당 👍
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.
테스트 코드 추가하신 거 좋아보여요 👍
}); | ||
}); | ||
|
||
test("음수 테스트", async () => { |
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 IS_CUSTOM = /^\/\/.*\\n/msu; | ||
// 커스텀 구분자를 확인하기 위한 정규표현식 | ||
|
||
const CUSTOM = IS_CUSTOM.exec(input); |
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.
CUSTOM을 대문자로 표현하신 이유가 있으실까용?
|
||
export default function process(input) { | ||
// 문자열 전처리 과정 | ||
let [string, custom] = preprocess(input); |
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.
지금은 preprocess
여서 이전에 무슨 처리를 하는 거구나 인식은 되지만, 정확히 어떤 처리인지는 잘 모르겠어요.
그래서 sanitizeInput
같은 걸로 바꿔봐도 좋을 거 같아용
function num_check(value) { | ||
const VALUE = Number(value); | ||
if (VALUE == NaN) throw new Error("[ERROR] 숫자만 더할 수 있어요."); | ||
else if (VALUE < 0) throw new Error("[ERROR] 양수만 더할 수 있어요."); | ||
else return VALUE; | ||
} |
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 num_check(value) {
const VALUE = Number(value);
if (isNaN(VALUE)) {
throw new Error("[ERROR] 숫자만 더할 수 있어요.");
}
if (VALUE < 0) {
throw new Error("[ERROR] 양수만 더할 수 있어요.");
}
return VALUE;
}
이렇게 if문을 따로 둘 수도 있을 거 같아용
No description provided.