CardProblem-2
Mon Oct 03 2022 11:24:41 GMT+0000 (Coordinated Universal Time)
Saved by
@j_jivan
#javascript
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,
},
];
// =============================================== 2 ================================================ //
let uniqSuit = new Set();
function getSuits(cardData) {
cardData.forEach((element) => {
uniqSuit.add(element.suit);
});
return Array.from(uniqSuit);
// write your code here
}
console.log(getSuits(cardData));
/**
2. write a function which returns the list of available suits in the above data
* ans => ["heart", "club", "diamond"]
*/
content_copyCOPY
Comments