Hannarita/다각형의 넓이 구하는 함수 만들기 완료#5
Conversation
|
랩의 커밋로그를 참고해서 비슷하게 해보시면 좋겠어요. |
index.js
Outdated
| @@ -0,0 +1,40 @@ | |||
| function circleSize(rad) { | |||
There was a problem hiding this comment.
함수이름은 동사+명사형태로 수정하세요. 즉 무엇을하다가 잘 표현되게.
There was a problem hiding this comment.
rad 보다는 정확한 전체 명사를 쓰세요. 읽기 좋게요.
index.js
Outdated
| @@ -0,0 +1,40 @@ | |||
| function circleSize(rad) { | |||
| if(typeof rad === 'string'){ | |||
There was a problem hiding this comment.
typeof 가 타입을 체크하는데 가진 한계가 있는데요.
이를 찾아서 마크다운 형식으로 정리해볼래요?
index.js
Outdated
| console.log('반지름은 0보다 커야합니다'); | ||
| } | ||
| else { | ||
| var size = rad * rad * Math.PI; |
There was a problem hiding this comment.
함수 윗부분에
var size=0;을 미리 선언해두고 여기서는
size = rad * rad * Math.PI로 적어둬도 좋아요.
이와 관련된 학습은 호이스팅 개념입니다.
|
|
||
| function rectSize(width,height) { | ||
| if(typeof width=== 'string'||typeof height === 'string'){ | ||
| console.log('숫자형타입만 계산이 가능합니다'); |
There was a problem hiding this comment.
이대로라면 배열이나 다른 타입이 들어가면 어떻게 처리되나요?
There was a problem hiding this comment.
조건을 타입이 넘버가 아니면 실행되게 변경했습니당
| } | ||
|
|
||
| function trapeSize(upper,bottom,height) { | ||
| if(arguments.length<=2){ |
There was a problem hiding this comment.
인자의 개수를 세고 싶어서 썼습니당
crongro
left a comment
There was a problem hiding this comment.
참고해서 수정해보시고, 다음 단계 풀어보세요
|
|
||
| function calculateTrapeSize(upper,bottom,height) { | ||
| if(arguments.length<=2){ | ||
| console.log('3개의 인자가 필요합니다'); |
There was a problem hiding this comment.
의도적으로 인자체크를 시도한 건 좋아요.
반드시 해야 하는 건 아닙니다.
그리고, 이미 getArea에서 인자를 3개 지정해서 넘겨주는데요. 여기서 이렇게 체크하는 게 맞을까요?
No description provided.