SHARE
TWEET

Untitled

a guest Jun 15th, 2019 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function buildDeck() {
  2.   const suits = ['spades', 'hearts', 'diamonds', 'clubs'];
  3.   const ranks = ['A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K'];
  4.   const deck = [];
  5.   for (let r = 0; r < ranks.length; r++) {
  6.     for (let s = 0; s < suits.length; s++) {
  7.       deck.push({ ranks: ranks[r], suits: suits[s], value: r + 1 });
  8.     }
  9.   }
  10.   return deck;
  11. }
  12. console.log(buildDeck())
  13.      
  14. const compare = (firstCard, secondCard) => {
  15.   const cardValue = firstCard.value - secondCard.value;
  16.   return cardValue;
  17. }
  18. console.log(compare());
  19.      
  20. const cardValue = firstCard.value - secondCard.value;                              
  21. TypeError: Cannot read property 'value' of undefined
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top