Skip to content
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

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

hhhkdev
Copy link

@hhhkdev hhhkdev commented Oct 21, 2024

No description provided.

Copy link

@anonymousRecords anonymousRecords left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

정규 표현식을 사용하고 substring()으로 커스텀 구분자로 추출한 로직이 인상깊었어요.
2주차도 기대하겠습니당 👍

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

테스트 코드 추가하신 거 좋아보여요 👍

});
});

test("음수 테스트", async () => {

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);

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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

지금은 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;
}

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문을 따로 둘 수도 있을 거 같아용

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants