Skip to content

Hannarita/다각형의 넓이 구하는 함수 만들기 완료#5

Merged
crongro merged 5 commits intocode-squad:masterfrom
hannarita:hannarita
Nov 15, 2017
Merged

Hannarita/다각형의 넓이 구하는 함수 만들기 완료#5
crongro merged 5 commits intocode-squad:masterfrom
hannarita:hannarita

Conversation

@hannarita
Copy link
Copy Markdown
Contributor

No description provided.

@crongro
Copy link
Copy Markdown
Contributor

crongro commented Nov 14, 2017

랩의 커밋로그를 참고해서 비슷하게 해보시면 좋겠어요.
좋은 커밋은 무엇인가 공부해보셔도 좋겠고요.

Copy link
Copy Markdown
Contributor

@crongro crongro left a comment

Choose a reason for hiding this comment

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

참고해서 수정해보세요.

index.js Outdated
@@ -0,0 +1,40 @@
function circleSize(rad) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

함수이름은 동사+명사형태로 수정하세요. 즉 무엇을하다가 잘 표현되게.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

rad 보다는 정확한 전체 명사를 쓰세요. 읽기 좋게요.

index.js Outdated
@@ -0,0 +1,40 @@
function circleSize(rad) {
if(typeof rad === 'string'){
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

typeof 가 타입을 체크하는데 가진 한계가 있는데요.
이를 찾아서 마크다운 형식으로 정리해볼래요?

index.js Outdated
console.log('반지름은 0보다 커야합니다');
}
else {
var size = rad * rad * Math.PI;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

함수 윗부분에
var size=0;을 미리 선언해두고 여기서는
size = rad * rad * Math.PI로 적어둬도 좋아요.

이와 관련된 학습은 호이스팅 개념입니다.


function rectSize(width,height) {
if(typeof width=== 'string'||typeof height === 'string'){
console.log('숫자형타입만 계산이 가능합니다');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

이대로라면 배열이나 다른 타입이 들어가면 어떻게 처리되나요?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

조건을 타입이 넘버가 아니면 실행되게 변경했습니당

}

function trapeSize(upper,bottom,height) {
if(arguments.length<=2){
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

arguments 를 쓴 이유가 뭐에요?

Copy link
Copy Markdown
Contributor Author

@hannarita hannarita Nov 15, 2017

Choose a reason for hiding this comment

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

인자의 개수를 세고 싶어서 썼습니당

Copy link
Copy Markdown
Contributor

@crongro crongro left a comment

Choose a reason for hiding this comment

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

참고해서 수정해보시고, 다음 단계 풀어보세요


function calculateTrapeSize(upper,bottom,height) {
if(arguments.length<=2){
console.log('3개의 인자가 필요합니다');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

의도적으로 인자체크를 시도한 건 좋아요.
반드시 해야 하는 건 아닙니다.

그리고, 이미 getArea에서 인자를 3개 지정해서 넘겨주는데요. 여기서 이렇게 체크하는 게 맞을까요?

@crongro crongro merged commit 4ca045a into code-squad:master Nov 15, 2017
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