I notice quite a lot of my code is duplicated purely because I do not know how to refactor it differently taking a variable into consideration.
This is the code inside my react render method:
if (card.suit == 'D' || card.suit == 'H'){
return <div className="cardFormatDH" key={ index }> {card.rankKey}{card.suit} </div>;
}
else if (card.suit == 'C' || card.suit == 'S'){
return <div className="cardFormatCS" key={ index }> {card.rankKey}{card.suit} </div>;
}
effectively what I would like to say is something like:
return exactly the same thing whether it is d/h or c/s, just allow c/s to have the same style and d/h to have the same style. also my if condition is quite long but I cant figure a way to shorten it down