Skip to content

Conversation

yxxndxxn
Copy link

@yxxndxxn yxxndxxn commented Feb 6, 2025

No description provided.

@ParkHyeonkyu
Copy link

고생하셨습니당
저의 얕은 지식으로,, 최대한 리뷰해보겠습니다

const customDelimiter = (input) => {
if (input.startsWith("//")) {
const endDelimiter = input.indexOf("\\n"); //마지막 찾기
if (endDelimiter == -1) {
Copy link

Choose a reason for hiding this comment

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

endDelimeter 가 -1일때 올바른 커스텀 구분자 형식이 되도록 한 논리가 무엇인가요?

@@ -1,5 +1,18 @@
import { Console } from "@woowacourse/mission-utils";
import Calculator from "./Calculator.js";
Copy link

Choose a reason for hiding this comment

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

Calculator 라이브러리 쓰신 이유가 궁금합니다..!!저는 Console 외의 라이브러리 없이 구현해서요..!!

const add = (input) => {
if (!input) return 0;

const numbers = splitDelimiter(input).map(validateNumber);
Copy link

Choose a reason for hiding this comment

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

이 부분 코드가 잘 이해가 안되서 혹시 설명해주실 수 있나요?

Copy link

@yuninam2128 yuninam2128 left a comment

Choose a reason for hiding this comment

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

코드 가독성이 좋은 것 같아요! 기능별로 나누어져있어서 읽기가 수월했던 것 같습니다. 수고하셨습니다!

throw new Error("양수가 아닙니다.");
}
return parsed;
};

Choose a reason for hiding this comment

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

숫자가 아닐 때도 양수가 아닐 때도 오류 메시지를 보낼 거니까, or을 사용해서 한 번에 묶으면 좀 더 간결하게 나타낼 수 있을 것 같습니다!

//기본 구분자
return numbers.split(/[,:]/).filter((num) => num !== "");
}
};

Choose a reason for hiding this comment

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

커스텀 구분자가 있으면 기본 구분자는 작동하지 않는 방식인 거 같네요
저는 정규 표현식을 사용해서
기존 기본 구분자들을 정규 표현식으로 포함시키고
커스텀 구분자를 구하면 [ ]안에 포함하는 방식을 써보았는데 차이점이 있군요

Choose a reason for hiding this comment

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

만약 둘 다 사용하려면
else를 사용하는 대신
21행으로 return한 값을 기본 구분자로 다시 구분해보는 방식을 쓰면 되겠네요

@@ -0,0 +1,47 @@
export default function Calculator() {

Choose a reason for hiding this comment

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

파일 분리를 하셔서 코드가 깔끔한 것 같아요
전 App하나로 다 해결하려다 보니 가독성이 조금 떨어졌는데
잘 보고 참고하겠습니다

- [x] 입출력 기능 구현
- [x] 기본 구분자(쉼표, 콜론)로 입력된 경우 계산
- [x] 커스텀 구분자로 입력된 경우 계산
- [x] 예외 처리

Choose a reason for hiding this comment

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

고려하신 예외가

  1. 커스텀 구분자 지정 형식 //@\n
  2. NaN
  3. 음수
    등이 있으신거 같아요
    저는 소수점 계산도 실행해보고 싶어서 .을 커스텀 구분자로 지정하지 못하게 했는데
    혹시 추가로 고려하신 예외가 더 있으신가요?

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.

4 participants