Preview:
const cardData = [
  {
    suit: "heart",
    value: 7,
  },
  {
    suit: "club",
    value: 8,
  },
  {
    suit: "club",
    value: 2,
  },
  {
    suit: "diamond",
    value: 2,
  },
  {
    suit: "diamond",
    value: 5,
  },
  {
    suit: "club",
    value: 10,
  },
];

// =========================================== 1 ==================================================== //

function findCard(value, suit) {
  for (let i = 0; i < cardData.length; ++i) {
    if (cardData[i].suit === suit && cardData[i].value === value) {
      return true;
    }
  }
  return false;
}
findCard(5, "heart");
findCard(10, "club");
/** * 1. complete the above function,
 * it should return true /false if card is present/absent
 * example
 * findCard(5, 'heart') should return false
 * findCard(10, 'club') should return true
 */
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter