JSFiddle - React, Tailwind, and code Playground

by jrab227

JavaScript

function Deck(Suits, Values) {
	if (Suits.length === 1 && Values.length === 1) return [[Suits[0], Values[0]]];
  
	if (Suits.length === 1) return Values.reduce((total, value) => 
    	total.concat(new Deck([Suits[0]], [value])), []);
      
  return Suits.reduce((total, suit) => 
    total.concat(new Deck([suit], Values)), []);
}

let deck = new Deck(["D", "H", "C", "S"], [1, 2, 3]);

//debugger