I am looking to build a function containing two string variables, and return the combination to each card of a deck.
playCard({ suit: 'HEARTS', value: 2 }) to return 2♥
playCard({ suit: 'SPADES', value: 10 }) to return T♠
playCard({ suit: 'SPADES', value: 11 }) to return J♠
You could do this with 2 simple lookup tables, or associative arrays
playCard
could have also be written like this:In my example above it simply used object destructuring assignment: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment