I am currently working on creating a simplified poker game using JavaScript. I have documented all potential card combinations that a player may have in their hand, organized by their value. Here's an example:
switch(sortedHand)
{
//Pair
case [1,1,4,3,2]: sortedHand.push(1,"Pair"); break;
case [1,1,5,3,2]: sortedHand.push(2,"Pair"); break;
case [1,1,5,4,2]: sortedHand.push(3,"Pair"); break;
case [1,1,5,4,3]: sortedHand.push(4,"Pair"); break;
case [1,1,6,3,2]: sortedHand.push(5,"Pair"); break;
case [1,1,6,4,2]: sortedHand.push(6,"Pair"); break;
case [1,1,6,4,3]: sortedHand.push(7,"Pair"); break;
case [1,1,6,5,2]: sortedHand.push(8,"Pair"); break;
case [1,1,6,5,3]: sortedHand.push(9,"Pair"); break;
case [1,1,6,5,4]: sortedHand.push(10,"Pair"); break;
Although the "sortedHand" array is successfully storing values (confirmed through console.log), the switch() statement consistently defaults to the default case, resulting in everyone having a straight flush. It seems like my approach of defining exact array values for comparison with "sortedHand" might be causing this issue, but I'm not sure what the correct approach should be. Is it feasible to utilize switch() in this manner?