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

fix: 인자로 빈 문자열이 들어올 경우 얼리리턴하도록 수정 #86

Merged
merged 2 commits into from
May 7, 2024

Conversation

kangju2000
Copy link
Contributor

Overview

[as-is]

hasBatchimhasSingleBachim 함수의 인자로 ''가 들어오는 경우 다음과 같은 에러가 발생합니다.

image

[to-be]

인자로 ''가 들어오는 경우 false로 얼리리턴하여 에러가 발생하지 않도록 수정합니다.

PR Checklist

  • I read and included theses actions below
  1. I have read the Contributing Guide
  2. I have written documents and tests, if needed.

Copy link

changeset-bot bot commented May 4, 2024

🦋 Changeset detected

Latest commit: 3d34ed3

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented May 4, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
es-hangul ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 4, 2024 2:52pm

Comment on lines +24 to +28
const lastChar = str[str.length - 1];

if(lastChar == null) {
return false;
}
Copy link
Member

Choose a reason for hiding this comment

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

str자체가 빈 값일때 얼리 리턴해주는것과,
연산 결과값인 lastChar이 null일때 얼리 리턴해주는것과 차이가 있나요?!

  if(str == null) {
    return false;
  }

Copy link
Contributor Author

@kangju2000 kangju2000 May 7, 2024

Choose a reason for hiding this comment

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

str이 ''로 오는 경우엔 nullish하지 않아 '' == null이 성립되지 않습니다!
하지만 이때 lastChar는 undefined가 되어 조건에 성립하게 됩니다.

만약 str 값만 보고 얼리리턴을 해야한다면 요렇게 하면 될 것 같아용

if (str === '') {
  return false;
}

Copy link
Member

@okinawaa okinawaa left a comment

Choose a reason for hiding this comment

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

감사합니다 ! ☺️

@okinawaa okinawaa merged commit 28fb57a into toss:main May 7, 2024
2 checks passed
@github-actions github-actions bot mentioned this pull request May 9, 2024
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.

None yet

2 participants