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
*/
Comments