// 定义麻将牌类class MahjongCard {
constructor(suit, rank) {
this.suit = suit;
this.rank = rank;
}}// 生成麻将牌数组const suits = ['万', '条', '筒'];const ranks = [1, 2, 3, 4, 5, 6, 7, 8, 9];function generateMahjongCards() {
const cards = [];
for (const suit of suits) {
for (const rank of ranks) {
cards.push(new MahjongCard(suit, rank));
}
}
return cards;}console.log(generateMahjongCards());
暂时没有评论,来抢沙发吧~