[문자열 덧셈 계산기] 이혁 미션 제출합니다.#571
Open
hhhkdev wants to merge 16 commits intowoowacourse-precourse:mainfrom
Open
Conversation
anonymousRecords
left a comment
There was a problem hiding this comment.
정규 표현식을 사용하고 substring()으로 커스텀 구분자로 추출한 로직이 인상깊었어요.
2주차도 기대하겠습니당 👍
| }); | ||
| }); | ||
|
|
||
| test("음수 테스트", async () => { |
There was a problem hiding this comment.
기본으로 제공된 예외 테스트에서
예외 테스트 -> 음수 테스트로 변경해주셔서 어떤 테스트인지 더 잘 보이게 된 거 같아요
| const IS_CUSTOM = /^\/\/.*\\n/msu; | ||
| // 커스텀 구분자를 확인하기 위한 정규표현식 | ||
|
|
||
| const CUSTOM = IS_CUSTOM.exec(input); |
|
|
||
| export default function process(input) { | ||
| // 문자열 전처리 과정 | ||
| let [string, custom] = preprocess(input); |
There was a problem hiding this comment.
지금은 preprocess여서 이전에 무슨 처리를 하는 거구나 인식은 되지만, 정확히 어떤 처리인지는 잘 모르겠어요.
그래서 sanitizeInput 같은 걸로 바꿔봐도 좋을 거 같아용
Comment on lines
+28
to
+33
| 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.
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문을 따로 둘 수도 있을 거 같아용
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.
No description provided.