-
Notifications
You must be signed in to change notification settings - Fork 10
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
level01.음양_더하기 #501
level01.음양_더하기 #501
Conversation
function solution(absolutes, signs) { | ||
var answer = 0; | ||
|
||
for (const [index, value] of absolutes.entries()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
배열에도 entries 키워드가 되는지 처음 알았네요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저도 배열에도 entries 키워드가 되는 것을 알게되고 자주 사용하게 되었어요!
속도적인 부분은 확인을 안해봐서 잘 모르겠지만
미리 배열의 length
를 구해서 기본적인 for문의 형태(for (let i=0; i<n; i++)
)로 사용해도 되지만
저는 개인적으로
- 미리 length의 변수를 선언하는 코드를 줄이고
- for문 안에서 배열의 index로 value를 접근하는 것(
absolutes[i]
)보다 가독성이 더 좋다고 느껴져서
entries
키워드를 자주 사용하게 되네요 :)
리뷰 감사합니다 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#510 (comment)
해당 이슈에서 궁금했던 부분들을 집어서 결론을 내려보았어요! 한 번 확인 부탁드립니다 :)
@@ -0,0 +1,8 @@ | |||
function solution(absolutes, signs) { | |||
var answer = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
문제에서 제공해준 키워드이긴 하지만... 변수에는 let을 쓰는 건 어떨까요?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var를 사용하지 않고 let을 사용하는 게 좋죠!!
이번 기회에 var 사용을 권장하지 않는 이유도 되짚어보면 좋을 것 같네요 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좋아요~~
📅 문제를 푼 날짜
🔗 문제 링크
💬 의견