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

resolve #137-luck-balance 문제풀이 및 문서추가 #138

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

heeveloper
Copy link
Collaborator

No description provided.

@heeveloper heeveloper requested a review from yeonjuan August 14, 2019 15:29
return (a[1] > b[1]) ? 1 : -1;
});

let numImportant = length - [...sorted].findIndex(x => x[1] === 1);
Copy link
Owner

Choose a reason for hiding this comment

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

[...sorted]

를 사용하는 이유가 있나요 ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

findIndex를 쓰려고 사용했습니다

const loseImportant = [...sorted].slice(length - numImportant, length - numImportant + limit);
const winImportant = [...sorted].slice(length - numImportant + limit);

const sumLuck = (unImportant.reduce((sum, [luck]) => sum + luck, 0) || 0) +
Copy link
Owner

Choose a reason for hiding this comment

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

(sum, [luck]) => sum + luck

반복되는 부분은 함수로 빼는것이 좋을것 같습니다.

return (a[1] > b[1]) ? 1 : -1;
});

let numImportant = length - [...sorted].findIndex(x => x[1] === 1);
Copy link
Owner

Choose a reason for hiding this comment

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

numImportant 아래의 unImportant, loseImportant, winImportant 와 이름 형식이 같은데
아랫것들은 배열이고 numImportant 는 number 로 보입니다.
배열의 경우 s 복수형을 쓰는것이 좋을것 같습니다.

let numImportant = length - [...sorted].findIndex(x => x[1] === 1);
numImportant = (numImportant > length) ? 0 : numImportant;

const unImportant = [...sorted].slice(0, length - numImportant);
Copy link
Owner

Choose a reason for hiding this comment

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

length - numImportant 반복되서 사용되는 부분은 상수로 선언하는게 좋을것 같습니다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

👌

Copy link
Owner

@yeonjuan yeonjuan left a comment

Choose a reason for hiding this comment

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

.

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