please fix the code: const suits = ["♥", "♦", "♣", "♠"];
const ranks = ["2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"];

class Card {
  constructor(suit, rank) {
    this.suit = suit;
    this.rank = rank;
  }
  
  toString() {
    return `${this.rank}${this.suit}`;
  }
}

function determineWinners(playerHands, boardCards) {
  const allHands = playerHands.map((hand) => [...hand, ...boardCards]);
  const bestHands = allHands.map((hand) => getBestHand(hand));
  const maxRank = Math.max(...bestHands.map((hand) => hand.rank));

  return bestHands.reduce((winners, hand, index) => {
    if (hand.rank === maxRank) {
      winners.push({
        playerId: index,
        winningCombinationId: hand.combination.id,
        winningCards: hand.cards,
      });
    }
    return winners;
  }, []);
}

function getBestHand(cards) {
  const combinations = [
    RoyalFlush,
    StraightFlush,
    FourOfAKind,
    FullHouse,
    Flush,
    Straight,
    ThreeOfAKind,
    TwoPairs,
    Pair
  ];

  for (const Combination of combinations) {
    const result = Combination.test(cards);
    if (result != null) {
      return { rank: Combination.rank, combination: result.combination, cards: result.cards };
    }
  }
}

class Combination {
  constructor(name, id, rank) {
    this.name = name;
    this.id = id;
    this.rank = rank;
  }

  static test(cards) {}
}



class StraightFlush extends Combination {
    constructor() {
        super("Straight flush", 8, 8);
    }

    static test(cards) {
        const counts = {};

        for (let card of cards) {
            counts[card.suit] = (counts[card.suit] || []).concat(card);
        }

        const flusharr = Object.keys(counts).filter((key, i, arr) => {
            if (counts[key].length >= 5) {
                return key;
            }
        });

        if (flusharr.length !== 1) {
            return null;
        }

        let flushCards = counts[flusharr];

        let sorted_rank = [...new Set(flushCards.map((card) => card.rank))].sort((a, b) => Number(b) - Number(a));

        const Ace = sorted_rank.includes("A") && sorted_rank.includes("K");
        const Sequentialized_Ace = ["5", "4", "3", "2"].includes(sorted_rank[0]) && Ace;

        if ((!Ace && sorted_rank.length < 5) || (!Sequentialized_Ace && sorted_rank.length < 5)) {
            return null;
        }

        if (Sequentialized_Ace) {
            sorted_rank.shift();
            sorted_rank.push("14");
        }

        let rank_index = 0,
            possible_straight = [sorted_rank[0]];

        for (let i = 1; i < sorted_rank.length; i++) {
            if (Number(sorted_rank[i - 1]) === Number(sorted_rank[i]) + 1) {
                possible_straight.push(sorted_rank[i]);
            } else if (Number(sorted_rank[i - 1]) !== Number(sorted_rank[i])) {
                rank_index = i;
                possible_straight = [sorted_rank[rank_index]];
            }

            let remainingCards = [];
            for (let i = 0; i < flushCards.length; i++) {
                let test = true;
                if (possible_straight.indexOf(flushCards[i].rank) !== -1) {
                    possible_straight.splice(possible_straight.indexOf(flushCards[i].rank), 1);
                    test = false;
                }

                if (test === true) {
                    remainingCards.push(flushCards[i]);
                }
            }

            if (possible_straight.length === 0) {
                let straightArr = [];
                for (let j = 0; j < flushCards.length; j++) {
                    if (sorted_rank.indexOf(flushCards[j].rank) !== -1) {
                        straightArr.push(flushCards[j]);
                    }
                }

                return {
                    combination: this,
                    cards: straightArr.slice(0, 5),
                };
            }
        }

        return null;
    }
}

/////////////////////
// Define a helper function to create a test hand with given cards
function createTestHand(...cards) {
  return cards.map((card) => new Card(card.suit, card.rank));
}

// Write the test function for StraightFlush combination
function testStraightFlush() {
  // Test Case 1 - when there is no straight flush
  const cards1 = createTestHand(
    { suit: "♥", rank: "9" },
    { suit: "♣", rank: "2" },
    { suit: "♠", rank: "J" },
    { suit: "♦", rank: "5" },
    { suit: "♠", rank: "K" },
    { suit: "♥", rank: "Q" },
    { suit: "♥", rank: "8" }
  );

  const result1 = StraightFlush.test(cards1);
  console.log(result1);

  // Test Case 2 - when there is a straight flush with Ace as the high card
  const cards2 = createTestHand(
    { suit: "♣", rank: 'A' },
    { suit: '♣', rank:'3' },
    {suit:'♣',rank:'4'},
    {suit:'♢',rank:'7'},
    {suit:'♢',rank:'5'},
       // straight flush of clubs up till Ace (with club Ace)
            {'suit':"♣",'rank':'6'},           
            {'suit':"♣",'rank':'7'},         
            {'suit':"▲",'rank':'10'},
            {'suit':"◆",'rank':'9'},
           {'suit':"■",'rank':'K'}

  );

  const result2 = StraightFlush.test(cards2);
  console.log(result2);
  // Test Case 3 - when there is a straight flush with Ace as the low card
   const cards3 = createTestHand({ suit: "♥", rank: "5" }, { suit: "♥", rank:"6" }, 
                        { suit: "♥", rank:"4" }, { suit: "♥", rank:"3" }, 
                        { suit: "♥", rank:"2" },"|",
						{ suit: "♠", rank:"A" }, { suit: "♦", rank:"8" }
  				);
  
						
						
						


    
    		const result3 = StraightFlush.test(cards3);
  console.log(result3);
}

// Call the test function
testStraightFlush();