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

level01.음양_더하기 #501

Merged
merged 1 commit into from
Oct 2, 2022
Merged

level01.음양_더하기 #501

merged 1 commit into from
Oct 2, 2022

Conversation

JiaLee0707
Copy link
Collaborator

📅 문제를 푼 날짜

  • 2022.09.09

🔗 문제 링크

💬 의견

function solution(absolutes, signs) {
var answer = 0;

for (const [index, value] of absolutes.entries()) {
Copy link
Member

Choose a reason for hiding this comment

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

배열에도 entries 키워드가 되는지 처음 알았네요!

Copy link
Collaborator Author

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++))로 사용해도 되지만

저는 개인적으로

  1. 미리 length의 변수를 선언하는 코드를 줄이고
  2. for문 안에서 배열의 index로 value를 접근하는 것(absolutes[i])보다 가독성이 더 좋다고 느껴져서

entries 키워드를 자주 사용하게 되네요 :)

리뷰 감사합니다 😁

Copy link
Member

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;
Copy link
Member

Choose a reason for hiding this comment

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

문제에서 제공해준 키워드이긴 하지만... 변수에는 let을 쓰는 건 어떨까요?!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

var를 사용하지 않고 let을 사용하는 게 좋죠!!
이번 기회에 var 사용을 권장하지 않는 이유도 되짚어보면 좋을 것 같네요 :)

Copy link
Member

Choose a reason for hiding this comment

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

좋아요~~

@JiaLee0707 JiaLee0707 merged commit bd63468 into master Oct 2, 2022
@JiaLee0707 JiaLee0707 deleted the JiaLee0707-patch-3 branch October 2, 2022 09:48
@areumsheep areumsheep mentioned this pull request Oct 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants