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

destructure parameters #2507

Merged
merged 2 commits into from
Jul 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
*
* @returns {Card} the first card in the deck
*/
export function getFirstCard(deck) {
const [first] = deck;

export function getFirstCard([first]) {
return first;
}

Expand All @@ -21,9 +19,7 @@ export function getFirstCard(deck) {
*
* @returns {Card} the second card in the deck
*/
export function getSecondCard(deck) {
const [, second] = deck;

export function getSecondCard([, second]) {
return second;
}

Expand All @@ -46,9 +42,7 @@ export function swapTopTwoCards([a, b, ...rest]) {
* @returns {[Card, Card[]]} the top card of the given
* deck and a new deck containing all the other cards
*/
export function discardTopCard(deck) {
const [first, ...rest] = deck;

export function discardTopCard([first, ...rest]) {
return [first, rest];
}

Expand Down