We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
freeCodeCampProject/poker-game/lib/compare.js
Line 96 in 57ce81b
关于数组的排序你写了3个函数: transformFunc、_isLargerThan、_comparator 来实现,代码互相缠绕,实在过于冗余。 其实只需一行即可:
let sortedValue = cardList.map(card => card.value).sort((a,b)=>b-a);
The text was updated successfully, but these errors were encountered:
德州扑克中花色是平级的,所以不应该在花色部分着墨过多,只需关注是否同花即可。 value 部分是显示给用户看的,也不应该过于关注。 代码中最重要的是比大小,所以应该用 value 对应的 number。 所以上面的代码应该修改成:
cardList.map(card => card.number).sort((a,b)=>b-a);
Sorry, something went wrong.
No branches or pull requests
freeCodeCampProject/poker-game/lib/compare.js
Line 96 in 57ce81b
关于数组的排序你写了3个函数: transformFunc、_isLargerThan、_comparator 来实现,代码互相缠绕,实在过于冗余。
其实只需一行即可:
The text was updated successfully, but these errors were encountered: