Skip to content

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

3 participants