52张扑克牌快速生成JavaScript版

 

function* generatePoker() {
        const points = ['A', 2, 3, 4, 5, 6, 7, 8, 9, 10, 'J', 'Q', 'K'];

        yield* points.map(p => ['♠️', p]);
        yield* points.map(p => ['♣️', p]);
        yield* points.map(p => ['♥️', p]);
        yield* points.map(p => ['♦️', p]);
    }
    const cards = generatePoker();

    function* shuffle(cards) {
        cards = [...cards];
        console.log(cards)
    }
    shuffle(cards).next()

  

posted @ 2019-02-03 11:06  地铁程序员  阅读(741)  评论(0编辑  收藏  举报